-
Notifications
You must be signed in to change notification settings - Fork 40
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
WIP: Use threads to allow more than one connection #140
Conversation
3fcb57e
to
abd410a
Compare
@jettify ? |
def __init__(self, | ||
client: socket.socket, | ||
addr: Tuple[str, int], | ||
monitor: Monitor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of sharing full monitor object safer to pass required arguments like thread_id/etc, less sharing better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I had planned on cleaning this up, but for the first impression, I just wanted to make it work.
self._console_future.result() | ||
console_proxy(self._sin, self._sout, self._host, self._console_port) | ||
if self._monitor._console_future is not None: | ||
self._monitor._console_future.result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering, if we can wait for console server to start when we init it instead of here. This should simplify things a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what you mean. Could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thinking if it is better to move _console_future.result()
closer where we actually create this future object.
aiomonitor/aiomonitor/monitor.py
Lines 108 to 109 in 230a351
self._console_future = init_console_server( | |
self._host, self._console_port, self._locals, self._loop) |
In current implementation we create future and wait it once we need to be sure that python console is started, instead doing this should we just wait console immediately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reworked this part of code in master
sin = client.makefile('r', encoding='utf-8') | ||
self._interactive_loop(sin, sout) | ||
except (socket.timeout, OSError): | ||
threading.Thread(target=CLI(client, addr, self)).start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this tread demonized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good idea.
I like the idea, do not see any big issues with threads. |
This will be resolved by backporting aiomonitor-ng. 😉 |
I'd like to have the possibility to connect more than once to a monitor, so I tried a threading approach.
This is still work in progress, I'd like someone who knows more about the gritty details of threads to have a look here. It seems to work well, but who knows what kind of bugs might lurk in the details.