-
Notifications
You must be signed in to change notification settings - Fork 365
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
Make Sync Client and Server reusable #1503
base: master
Are you sure you want to change the base?
Changes from 1 commit
b80ffac
dff554a
5846fea
8dab330
fa02bab
7be113d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,9 +249,12 @@ def application_uri(self): | |
def application_uri(self, value): | ||
self.aio_obj.application_uri = value | ||
|
||
@syncmethod | ||
def connect(self) -> None: | ||
pass | ||
if not self.tloop.is_alive(): | ||
self.tloop = ThreadLoop() | ||
self.tloop.start() | ||
self.close_tloop = True | ||
self.tloop.post(self.aio_obj.connect()) | ||
|
||
def disconnect(self) -> None: | ||
try: | ||
|
@@ -592,9 +595,12 @@ def register_namespace(self, url): | |
def get_namespace_array(self): | ||
pass | ||
|
||
@syncmethod | ||
def start(self): | ||
pass | ||
if not self.tloop.is_alive(): | ||
self.tloop = ThreadLoop() | ||
self.tloop.start() | ||
self.close_tloop = True | ||
self.tloop.post(self.aio_obj.start()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arrg same code again... Making that class re-usable might not be a good idea. there is probably a reason, threading.Thread is not reusable... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your time and effort, but could you clarify further, since I'm not quite sure in what way initializing a new Thread or ThreadLoop could pose a problem in this context. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was simply refering to the fact the threading.Thread in the python standard library does not allow re-use. We copied their API when creating that class. We can make that class reusable, but I see your code over is not really clean, so maybe it is hard to solve that issue in a safe way... |
||
|
||
def stop(self): | ||
self.tloop.post(self.aio_obj.stop()) | ||
|
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.
we cannot have the same code several places. At least put that code in a method.
also if you want to delay threadloop initializatin, you might need to do it at several places not only here... there is a connect_sessionless method for example and maybe others...