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

Using thread-safe version of timeout decorator in a serwer #29

Open
wojciech-galan opened this issue Sep 15, 2016 · 1 comment
Open

Comments

@wojciech-galan
Copy link

I've got a server using ThreadingMixIn:

class ThreadingTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
    pass

class RequestHandler(SocketServer.StreamRequestHandler):

    @timeout_decorator.timeout(seconds=5, use_signals=False)
    def handle(self):
        #do some time-consuming stuff

if __name__ == '__main__':
    server = ThreadingTCPServer((server_ip, server_port), RequestHandler)
    server.serve_forever()

When I run the server and a client sending requests to the server, I get the following error:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/SocketServer.py", line 599, in process_request_thread
    self.handle_error(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/local/lib/python2.7/dist-packages/timeout_decorator/timeout_decorator.py", line 132, in __call__
    return self.value
  File "/usr/local/lib/python2.7/dist-packages/timeout_decorator/timeout_decorator.py", line 154, in value
    raise load
TypeError: handle() takes exactly 1 argument (0 given)

Is there something wrong with my code?

@bitranox
Copy link

bitranox commented Nov 9, 2017

You can try my Version, its using wrapt instead functools - it should behave correctly :
https://github.com/bitranox/timeout-decorator
Yours sincerely
Robert

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