Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 57 after 20 queries using SocketNER #7

Closed
dcalacci opened this issue Nov 21, 2013 · 2 comments
Closed

Error 57 after 20 queries using SocketNER #7

dcalacci opened this issue Nov 21, 2013 · 2 comments

Comments

@dcalacci
Copy link

Consistently, if I have the stanford NER server running on my local machine, and I use pyner to make 20 consecutive queries - it doesn't matter how far apart in time they are - I receive the following error message and trace:

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ner-0.1-py2.7.egg/ner/client.pyc in get_entities(self, text)
     74         :returns: a dict of entity type to list of entities of that type
     75         """
---> 76         tagged_text = self.tag_text(text)
     77         if self.oformat == 'slashTags':
     78             entities = self.__slashTags_parse_entities(tagged_text)

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ner-0.1-py2.7.egg/ner/client.pyc in tag_text(self, text)
    117         with tcpip4_socket(self.host, self.port) as s:
    118             s.sendall(text)
--> 119             tagged_text = s.recv(10*len(text))
    120         return tagged_text
    121 

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.pyc in __exit__(self, type, value, traceback)
     22         if type is None:
     23             try:
---> 24                 self.gen.next()
     25             except StopIteration:
     26                 return

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ner-0.1-py2.7.egg/ner/utils.pyc in tcpip4_socket(host, port)
     15         yield s
     16     finally:
---> 17         s.shutdown(socket.SHUT_RDWR)
     18         s.close()
     19 

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.pyc in meth(name, self, *args)
    222 
    223 def meth(name,self,*args):
--> 224     return getattr(self._sock,name)(*args)
    225 
    226 for _m in _socketmethods:

error: [Errno 57] Socket is not connected

I can use other ner client libraries to make consecutive requests, so I'm doubtful that the issue lies with the server code.

@dcalacci
Copy link
Author

after some digging, it seems like this is an issue with py-amqplib:
https://code.google.com/p/py-amqplib/issues/detail?id=45

But, because of this bug, I can't successfully use the stanford ner server running on a socket using the pyner package on my machine, because I'm running OSX.

@dat
Copy link
Owner

dat commented Nov 25, 2013

Alternatively, you can your local copy to call s.shutdown(...) between line 15 and 16 here. That way the exception is still handled and your socket will still close on OS X.

/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ner-0.1-py2.7.egg/ner/utils.pyc in tcpip4_socket(host, port)
15 yield s
16 finally:
---> 17 s.shutdown(socket.SHUT_RDWR)
18 s.close()
19

dat added a commit that referenced this issue Jan 20, 2014
handle socket error (for issue #7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants