-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement asyncio Based faradayio #65
Comments
Playing with this last night I am coming to a few conclusions:
The reason for I was able to get |
Notes from tonights work on
|
Per #64 thanks to the help of @reillyeon and @hdkmike it's apparent I need to start looking at
asyncio
. This is one of the larger packages in and reasons for moving to Python 3. As discussed in #64 there's a delay in servicing packets because of waiting for timeouts to occur.TUN
pytun
does not even implement a timeout. It uses standard C reads in Linux and therefore will block until the expected amount of data is received. Therefore. I placed a timeout decorator infaradayio
for thecheckTUN()
function. This was done in 2f582ae to stop the module from blocking.Serial
The
pyserial
does not block and defaults to reading with no timeout. This means it will receive up to the amount requested but if not then it will immediately return with what it has. As shown in #64 this results in a small delay.Running TUN and Serial Together
Currently, the TUN and serial interfaces are checked with the
run()
function. This is a loop that is spun off in a thread to repeatedly poll the TUN and serial ports. While this works, the obvious problem is that we must wait for timeouts to occur on each interface and cannot react when data is immediately available.This is where
asyncio
comes in. The module is designed to allow asynchronous operation of "coroutines" which allow immediate action on data available on interfaces.Testing
There is information on how to test with
asyncio
. However, I've had trouble before on #3 though I may know enough now to solve the issues. I am not sure if I want to embark on a test driven development path here or solve the problem. I'll think about it.The text was updated successfully, but these errors were encountered: