Skip to content

Make gevent and gevent_uswgi async drivers compatible with threading.… - #245

Closed
dedoussis wants to merge 2 commits into
miguelgrinberg:mainfrom
dedoussis:main
Closed

Make gevent and gevent_uswgi async drivers compatible with threading.…#245
dedoussis wants to merge 2 commits into
miguelgrinberg:mainfrom
dedoussis:main

Conversation

@dedoussis

Copy link
Copy Markdown

…Thread interface

Fixes: #244

def __init__(self, target, args=[], kwargs={}):
super(Thread, self).__init__(target, *args, **kwargs)

def _run(self):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not part of the threading.Thread interface.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why is this a problem? The Thread class in this driver is used internally.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I couldn't find any occurrences of this method being used anywhere in the codebase and since this is a private method, I decided to not include it anymore. If that's not the case, I'm more than happy to put it back 👍

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my question wasn't directly related to the _run() method, I was wondering about the whole change. I don't see any benefit in switching to the Thread class instead of using the Greenlet class as I'm doing here. There's nothing wrong with with the Thread class as far as I know, but my solution based on Greenlet has years of testing, so I'm not sure it makes sense to switch to a different implementation without a good reason.

But in any case, you asked about the _run() method. This is where you put the code that runs in the greenlet. You can see how this works in the documentation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the _run() clarification, that makes complete sense then. I will include it in the class, if we decide to go forward with this PR.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #245 (3f7b14b) into main (38c90ed) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #245   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         1894      1896    +2     
  Branches       343       343           
=========================================
+ Hits          1894      1896    +2     
Impacted Files Coverage Δ
src/engineio/async_drivers/gevent.py 100.00% <100.00%> (ø)
src/engineio/async_drivers/gevent_uwsgi.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 38c90ed...3f7b14b. Read the comment docs.

@miguelgrinberg

Copy link
Copy Markdown
Owner

As stated in the issue, I don't really see what is the improvement this change brings to the project. Did you have any problems with the current implementation?

@miguelgrinberg

Copy link
Copy Markdown
Owner

I will not be merging this change, as discussed in #244.

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.

Gevent's async driver is not compatible with the native threading.Thread interface.

3 participants