Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves #71. There are 2 main aspects to this PR:
Tnz.wait()
to that Tnz instance, but allow Ati to request the same event be used by multiple instances.asyncio.get_event_loop()
to choose the loop for each Tnz instance, by default. But allow a user to control the loop that is used to allow multiple threads to work with their own Tnz instances.These changes required some refactoring. Previously, event handling centered around global variables/functions in
tnz.py
that were used_sigx.py
,_termlib.py
, andzti.py
. This processing has been simplified andzti.py
becomes the central point of control. A newAti.get_asyncio_event_loop()
method is used to get the necessary data for that control. This includes both handling of stdin and signals.In general,
asyncio.get_event_loop()
is used to determine the event loop. Although this is not recommended when there is no running event loop (and no event loop has been set), it has historically be used and this is not changed at this time. This allows a user to control the event loop used by setting the event loop - though there are some levels of Python (but not the most recent) that will issue a deprecations warning whenasynci.get_event_loop()
is used and there is no running event loop - regardless if one has been set or not.The one exception is when setting the first Ati session. In that case, a new event loop is always created with
asyncio.new_event_loop()
. The intent is to ensure that the event loop used is never one that is currently running.The choice of the event loop on Windows has always been more difficult since the default Windows event loop is the ProactorEventLoop - an event loop that does not support
add_reader()
. But it just so happens that the requirement for another thread to transfer the stdin helps to eliminate the requirement foradd_reader()
. With this PR, special code to avoid the ProactorEventLoop has been removed and instead, the thread used to transfer stdin will wakeup the event loop instead ofadd_reader()
. Once the use ofadd_reader()
was removed, there was no need for the extra socket for Windows (which had annoying ConnectionResetErrors).