You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been thinking of converting the code revolving around reading from the tshark subprocess (and parsing the xml) from its current state (threads) into the far-better async io paradigm.
Particularly, I thought about using asyncio (the trollius version, to keep py2.7 support) which has good support for reading from subprocesses, even on Windows. I have a basic implementation working already.
I pose this question because converting to asyncio may hurt the "interactive" usage of the package, as eventloops don't work well with them and so code like:
forpacketincap:
# Do something with packet
May turn into something more like:
cap.for_each_packet(do_something_with_packet_callback)
# This will now block and call the function for each packet.
Though something can be implemented to still perform the interactivity and simple code as above, it will require to constantly start and stop the event loop, which might be okay if you're working interactively.
The advantages to this sort of approach is twofold:
Easy insertion of pyshark into other packages that work with eventloops (be it asyncio, twisted, tornado..)
Removing the issues and uncertainty (which you can see in past issues) that comes with threads.
I'd be happy to hear any opinions on the matter.
The text was updated successfully, but these errors were encountered:
I played with this a bit, as you mentioned. Not being very familiar with Twisted-style programming, I thought it could be possible to integrate that with pyshark as-is.
The more I read the more I found warnings that aysnc-style code is hard to bolt onto non-async code - the reactor pattern just doesn't fit well with other patterns. But I'll give your version a whirl.
I've been thinking of converting the code revolving around reading from the tshark subprocess (and parsing the xml) from its current state (threads) into the far-better async io paradigm.
Particularly, I thought about using asyncio (the trollius version, to keep py2.7 support) which has good support for reading from subprocesses, even on Windows. I have a basic implementation working already.
I pose this question because converting to asyncio may hurt the "interactive" usage of the package, as eventloops don't work well with them and so code like:
May turn into something more like:
Though something can be implemented to still perform the interactivity and simple code as above, it will require to constantly start and stop the event loop, which might be okay if you're working interactively.
The advantages to this sort of approach is twofold:
I'd be happy to hear any opinions on the matter.
The text was updated successfully, but these errors were encountered: