Open
Conversation
this code was developed with the help of Github Copilot.
anacso17
requested changes
Mar 24, 2026
This code was done with the help of Google AI Mode. Since the nest_asyncio package was archived, we implemented again a solution based on running a different event loop in a new thread however, this thread is long lived and all tasks are submitted using asyncio.run_coroutine_threadsafe function. Which guarantees that exceptions will be passed to the end user and that there will be no infinite hangs.
anacso17
approved these changes
Mar 30, 2026
Simplifies request logic by removing the need for a return_json flag, centralizing response deserialization, and improving error handling for timeouts and payload issues. Enhances code clarity by isolating JSON/text parsing and standardizing return values. Prepares for more robust integration and debugging in asynchronous workflows.
…where IP address, instead of server name is defined.
…control room (bug already in master).
xresende
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When we updated the
clientarchsubpackage to use asynchronous requests to the server under the hood, we implemented it so that allasyncmethods run in a separate thread. This was initially thought to be necessary to avoid conflicts in environments where an event loop is already running, such as Jupyter notebooks.However, this approach introduces several issues. Exceptions raised in that separate thread cannot be caught by the end user, and errors do not interrupt the execution flow as expected. In addition, there are cases where the thread silently dies, causing user calls to hang indefinitely.
It turns out there is a better way to runasyncmethods under the hood without exposingasyncin the public API. This PR attempts to implement that approach. Most of the implementation was done by GitHub Copilot, with a few manual adjustments on my part. One of those changes is the introduction of a dependency on thenest_asynciopackage.Since the
nest_asynciopackage was archived, we implemented again a solution based on running a different event loop in a new thread. However, this thread is long lived and all tasks are submitted usingasyncio.run_coroutine_threadsafefunction. This guarantees that exceptions will be passed to the end user and that there will be no infinite hangs.This last version of the code was done with the help of Google AI Mode.
This PR also solves a bug related on how to properly use
aiohttp. Now thejsonparsing of the response happens within aasync withfor the get resquest. Thanks to @anacso17 for helping with this debugging.The bug fix above, made it impossible to keep the old method to check for connection in the
ClientArchiver.connectedproperty, since we need to convert the response, either tojsonor totextwithin theasync withcontext manager. For this reason, the optionreturn_jsonwas removed. Now all requests will return data injsonformat, falling back to pure text data whenjsonconversion fails, which is the case of theClientArchiver.connectedmethod.This PR also fixes the
ClientArchiver.login()method that was not working in computers where the server is defined by its IP address, instead of its hostname (control room computers).This version of the code was tested in our conda environments and at the control room.