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
Selecting jobs based on job's name #934
Conversation
By selecting jobs based on their names users can manage jobs in job_queue. This new function return a tuple of jobs with the same name given as parameter.
select job based on job's name
Codecov Report
@@ Coverage Diff @@
## master #934 +/- ##
==========================================
- Coverage 91.8% 91.78% -0.03%
==========================================
Files 103 103
Lines 4040 4042 +2
Branches 638 639 +1
==========================================
+ Hits 3709 3710 +1
- Misses 193 194 +1
Partials 138 138
|
Hi, Thanks for your contribution. I would like to see some tests for the new method (selecting none, one and multiple). This will also hit the coverage target. |
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.
See comment on the code, but basically this code is not thread safe and a different approach is required.
telegram/ext/jobqueue.py
Outdated
def select_job(self, name): | ||
"""Returns a tuple of jobs with the given name that are currently in the ``JobQueue``""" | ||
|
||
return tuple(job[1] for job in self.queue.queue if job and job[1].name==name) |
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.
- Accessing
self.queue.queue
is not thread safe. We need a different approach here. - code style: you're missing spaces around
==
...
@Eldinnie I'm not sure, what do you mean about selecting none, one and multiple. So I run the following codes to test: Codes:
outputs:
@tsnoam At sleep duration I run the same script, multiple time by my machine and it seems thread safe. If this method is not thread safe so the method |
@paradox70 Look in the Regarding the threadsafety, we will have to look into that a bit more. I also alerted @tsnoam it's practically identical to the |
@paradox70 |
@paradox70
|
Due to lack of response from PR creator, closing the PR. |
This new function
select_job(name=)
returns a tuple of jobs with the given name that are currently in theJobQueue