-
Notifications
You must be signed in to change notification settings - Fork 58
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
Remove gevent #6
base: develop
Are you sure you want to change the base?
Conversation
… this repository, it seems it is not needed. In fact, the current implementation fails to forward messages received from the server to a callback registered via `some_hub.client.on('method', callback)`. The reason for this is that the listener which polls for incoming messages is spawned via gevent.spawn(listener), but (at least in the source code of this repository) no other method such as gevent.joinall() is ever called. This results in the listener never actually running. The new proposed implementation uses standard Python threads instead and fixes the problem that messages received from the server are not processed.
Hi, thank you for the pull request. The main reason to use gevent was its better resources utilization comparing to threads (as we used it with locust.io for load testing out main application web APIs). During the early phases of signalr-client-py development we've faced the similar issue. The solution was to enable gevent monkey patching like from gevent import monkey
monkey.patch_socket() Let me know if that's the case. If yes I'll add add gevent monkey patching to init file to be done automatically when referenced. Please share you thoughts. |
Hi, you're welcome - thank you for sharing your code to begin with! I have never used gevent before but I can see why you had the need for it. I don't think enabling gevent monkey patching will help. I tried the following:
I strongly suspect that your load testing script calls What would you think of the following suggestion: See if
This way, your code would continue to run and mine would run also. Also, the fact that |
Hi, I see now what you mean. There is no context switch in your sample. We used explicit calls to gevent.sleep in our tests. But maybe we should consider alternative approaches. I'll look into the issue deeper and let you know of results. |
Hi, I've created an example signalr application (ASP.NET vNext chat) as well as python client for it. I'll post some instructions on how to launch it later. I've also moved gevent It illustrates the way we use signalr client now. As you can see there is no need for you to call something like Please let me know your thoughts on the matter. Thank you. |
Hi, firstly, thank you for mentioning me as a contributor! Also, thank you for asking my opinion. I do want to answer, but in the interest of the project I will be very honest. I hope you don't mind: I think it's a mistake to make Having said that, it's of course your project and completely up to you what to make of it. If you want my feedback, I would suggest making Take care! |
@mherrmann I have made a fork based on your changes |
@PawelTroka cool! :) |
The current implementation fails to forward messages received from the server to a callback registered via
some_hub.client.on('method', callback)
. The reason for this is that the listener which polls for incoming messages is spawned viagevent.spawn(listener)
, but (at least in the source code of this repository) no other method such asgevent.joinall()
is ever called. This results in the listener never actually running. This pull request replacesgevent
by standard Python threads to fix the problem. As a result, the dependency ongevent
can be dropped.