-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Asyncore simple requester #187
Comments
I think the misunderstanding here is that with asynchronous model you prepare/send all your queries and later in time you fire up the main I/O loop which might send out pending packets and will wait for all the responses from the peers that are expected to respond eventually. Here is your code I tried to rework a bit along the lines above:
|
Ah, you can interleave these build/wait phases, the main thing is that you should only drop into the waiting state after you are done all the more urgent stuff, because waiting might take time (up to a timeout or a timer tick). |
@etingof , thank you for your attention! And if i want to send another request immediately after i've runned Dispatcher, i have to run multiple Requesters in different threads and to have common queue ? |
No-no-no! That would be a weird mix of asynchronous and threaded models (which would work though). I think we need to define "immediately"... Generally, the whole thing is event-driven. So you need an event to trigger your request scheduling code. The event could be for example a reception of a response (or timeout). Or if there is no specific event to piggyback on, you can register your own callable with transport dispatcher so you get your code run every once in a while where you could decide is it time to schedule another query or not yet. Once you return from your timer function, the control is back to the hands of the main loop. |
For example, another instance (let call it Boss) has my Requester as a property. |
Yes, but we need an event to break out of the waiting main loop e.g.
This way, while being in |
Can i check if my dispatcher is running? i.e. should i |
Typically, you run main loop (runDispatcher() just once at the end of your script), the main loop is a blocking call e.g. it might only return when no pending requests left. All the live happens in your callback functions being triggered by external events. You can make |
In my case
seems right choise for my task. If user want to send first and second requests (from example above), and then want to send third and other requests after that - should i run my dispatcher in separate thread and make it run forever, looking at list/array/queue of new requests ? For now end up with running dispatcher in separate thread - looks awkward... appreciate any other suggestions!
|
Hello!
I want to make simple asyncronius snmp-requester.
I take example from snmplabs.com
The questions are :
The text was updated successfully, but these errors were encountered: