Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

yggdr
Copy link
Contributor

@yggdr yggdr commented Sep 28, 2018

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.

@asvetlov
Copy link
Member

@jettify ?

def __init__(self,
client: socket.socket,
addr: Tuple[str, int],
monitor: Monitor
Copy link
Member

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

Copy link
Contributor Author

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()
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

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?

Copy link
Member

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()
Copy link
Member

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?

Copy link
Contributor Author

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.

@jettify
Copy link
Member

jettify commented Oct 2, 2018

I like the idea, do not see any big issues with threads.

@achimnol
Copy link
Member

This will be resolved by backporting aiomonitor-ng. 😉

@achimnol achimnol closed this Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants