8000 Make timeout parameter changes · aayn/stanford-corenlp-python@d498b66 · GitHub
[go: up one dir, main page]

Skip to content
< 10000 script crossorigin="anonymous" type="application/javascript" src="https://github.githubassets.com/assets/sessions-eed3aa0554dd.js" defer="defer">

Commit d498b66

Browse files
committed
Make timeout parameter changes
1 parent 8c3034d commit d498b66

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

corenlp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,23 +157,23 @@ def __init__(self, corenlp_path=None):
157157
sys.exit(1)
158158

159159
# spawn the server
160-
start_corenlp = "%s -Xmx1800m -cp %s %s %s" % (java_path, ':'.join(jars), classname, props)
160+
start_corenlp = "%s -Xmx10g -cp %s %s %s" % (java_path, ':'.join(jars), classname, props)
161161
if VERBOSE:
162162
logger.debug(start_corenlp)
163163
self.corenlp = pexpect.spawn(start_corenlp)
164164

165165
# show progress bar while loading the models
166166
widgets = ['Loading Models: ', Fraction()]
167167
pbar = ProgressBar(widgets=widgets, maxval=5, force_update=True).start()
168-
self.corenlp.expect("done.", timeout=20) # Load pos tagger model (~5sec)
168+
self.corenlp.expect("done.", timeout=2000) # Load pos tagger model (~5sec)
169169
pbar.update(1)
170-
self.corenlp.expect("done.", timeout=200) # Load NER-all classifier (~33sec)
170+
self.corenlp.expect("done.", timeout=20000) # Load NER-all classifier (~33sec)
171171
pbar.update(2)
172-
self.corenlp.expect("done.", timeout=600) # Load NER-muc classifier (~60sec)
172+
self.corenlp.expect("done.", timeout=60000) # Load NER-muc classifier (~60sec)
173173
pbar.update(3)
174-
self.corenlp.expect("done.", timeout=600) # Load CoNLL classifier (~50sec)
174+
self.corenlp.expect("done.", timeout=60000) # Load CoNLL classifier (~50sec)
175175
pbar.update(4)
176-
self.corenlp.expect("done.", timeout=200) # Loading PCFG (~3sec)
176+
self.corenlp.expect("done.", timeout=20000) # Loading PCFG (~3sec)
177177
pbar.update(5)
178178
self.corenlp.expect("Entering interactive shell.")
179179
pbar.finish()

jsonrpc.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
close ('127.0.0.1', 31415)
4545
4646
Client with JsonRPC2.0 and an abstract Unix Domain Socket::
47-
47+
4848
>>> proxy = ServerProxy( JsonRpc20(), TransportUnixSocket(addr="\\x00.rpcsocket") )
4949
>>> proxy.hi( message="hello" ) #named parameters
5050
u'hi there'
@@ -56,7 +56,7 @@
5656
u'hello world'
5757
5858
Server with JsonRPC2.0 and abstract Unix Domain Socket with a logfile::
59-
59+
6060
>>> server = Server( JsonRpc20(), 10000 TransportUnixSocket(addr="\\x00.rpcsocket", logfunc=log_file("mylog.txt")) )
6161
>>> def echo( s ):
6262
... return s
@@ -174,7 +174,7 @@
174174
PERMISSION_DENIED : "Permission denied.",
175175
INVALID_PARAM_VALUES: "Invalid parameter values."
176176
}
177-
177+
178178
#----------------------
179179
# exceptions
180180

@@ -189,7 +189,7 @@ class RPCTimeoutError(RPCTransportError):
189189

190190
class RPCFault(RPCError):
191191
"""RPC error/fault package received.
192-
192+
193193
This exception can also be used as a class, to generate a
194194
RPC-error/fault message.
195195
@@ -304,7 +304,7 @@ def dumps_request( self, method, params=(), id=0 ):
304304
- id: if id=None, this results in a Notification
305305
:Returns: | {"method": "...", "params": ..., "id": ...}
306306
| "method", "params" and "id" are always in this order.
307-
:Raises: TypeError if method/params is of wrong type or
307+
:Raises: TypeError if method/params is of wrong type or
308308
not JSON-serializable
309309
"""
310310
if not isinstance(method, (str, unicode)):
@@ -346,7 +346,7 @@ def dumps_error( self, error, id=None ):
346346
347347
Since JSON-RPC 1.0 does not define an error-object, this uses the
348348
JSON-RPC 2.0 error-object.
349-
349+
350350
:Parameters:
351351
- error: a RPCFault instance
352352
:Returns: | {"result": null, "error": {"code": error_code, "message": error_message, "data": error_data}, "id": ...}
@@ -480,7 +480,7 @@ def dumps_request( self, method, params=(), id=0 ):
480480
:Returns: | {"jsonrpc": "2.0", "method": "...", "params": ..., "id": ...}
481481
| "jsonrpc", "method", "params" and "id" are always in this order.
482482
| "params" is omitted if empty
483-
:Raises: TypeError if method/params is of wrong type or
483+
:Raises: TypeError if method/params is of wrong type or
484484
not JSON-serializable
485485
"""
486486
if not isinstance(method, (str, unicode)):
@@ -527,7 +527,7 @@ def dumps_response( self, result, id=None ):
527527

528528
def dumps_error( self, error, id=None ):
529529
"""serialize a JSON-RPC-Response-error
530-
530+
531531
:Parameters:
532532
- error: a RPCFault instance
533533
:Returns: | {"jsonrpc": "2.0", "error": {"code": error_code, "message": error_message, "data": error_data}, "id": ...}
@@ -675,7 +675,7 @@ def logfile( message ):
675675

676676
class Transport:
677677
"""generic Transport-interface.
678-
678+
679679
This class, and especially its methods and docstrings,
680680
define the Transport-Interface.
681681
"""
@@ -695,7 +695,7 @@ def sendrecv( self, string ):
695695
return self.recv()
696696
def serve( self, handler, n=None ):
697697
"""serve (forever or for n communicaions).
698-
698+
699699
- receive data
700700
- call result = handler(data)
701701
- send back result if not None
@@ -736,7 +736,7 @@ def recv(self):
736736
import socket, select
737737
class TransportSocket(Transport):
738738
"""Transport via socket.
739-
739+
740740
:SeeAlso: python-module socket
741741
:TODO:
742742
- documentation
@@ -771,7 +771,7 @@ def close( self ):
771771
self.s = None
772772
def __repr__(self):
773773
return "<TransportSocket, %s>" % repr(self.addr)
774-
774+
775775
def send( self, string ):
776776
if self.s is None:
777777
self.connect()
@@ -798,7 +798,7 @@ def sendrecv( self, string ):
798798
self.close()
799799
def serve(self, handler, n=None):
800800
"""open socket, wait for incoming connections and handle them.
801-
801+
802802
:Parameters:
803803
- n: serve n requests, None=forever
804804
"""
@@ -828,7 +828,7 @@ def serve(self, handler, n=None):
828828

829829

830830
if hasattr(socket, 'AF_UNIX'):
831-
831+
832832
class TransportUnixSocket(TransportSocket):
833833
"""Transport via Unix Domain Socket.
834834
"""
@@ -846,7 +846,7 @@ def __init__(self, addr=None, limit=4096, timeout=5.0, logfunc=log_dummy):
846846
class TransportTcpIp(TransportSocket):
847847
"""Transport via TCP/IP.
848848
"""
849-
def __init__(self, addr=None, limit=4096, timeout=5.0, logfunc=log_dummy):
849+
def __init__(self, addr=None, limit=12000000, timeout=30.0, logfunc=log_dummy):
850850
"""
851851
:Parameters:
852852
- addr: ("host",port)
@@ -939,7 +939,7 @@ def __call__(self, *args, **kwargs):
939939
class Server:
940940
"""RPC-server.
941941
942-
It works with different data/serializers and
942+
It works with different data/serializers and
943943
with different transports.
944944
945945
:Example:
@@ -980,7 +980,7 @@ def log(self, message):
980980

981981
def register_instance(self, myinst, name=None):
982982
"""Add all functions of a class-instance to the RPC-services.
983-
983+
984984
All entries of the instance which do not begin with '_' are added.
985985
986986
:Parameters:
@@ -1000,7 +1000,7 @@ def register_instance(self, myinst, name=None):
10001000
self.register_function( getattr(myinst, e), name="%s.%s" % (name, e) )
10011001
def register_function(self, function, name=None):
10021002
"""Add a function to the RPC-services.
1003-
1003+
10041004
:Parameters:
10051005
- function: function to add
10061006
- name: RPC-name for the function. If omitted/None, the original
@@ -1010,7 +1010,7 @@ def register_function(self, function, name=None):
10101010
self.funcs[function.__name__] = function
10111011
else:
10121012
self.funcs[name] = function
1013-
1013+
10141014
def handle(self, rpcstr):
10151015
"""Handle a RPC-Request.
10161016
@@ -1064,10 +1064,9 @@ def handle(self, rpcstr):
10641064

10651065
def serve(self, n=None):
10661066
"""serve (forever or for n communicaions).
1067-
1067+
10681068
:See: Transport
10691069
"""
10701070
self.__transport.serve( self.handle, n )
10711071

10721072
#=========================================
1073-

0 commit comments

Comments
 (0)
0