Selecting jobs based on job's name#934
Selecting jobs based on job's name#934paradox70 wants to merge 4 commits intopython-telegram-bot:masterfrom paradox70:master
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. |
tsnoam
left a comment
There was a problem hiding this comment.
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.
- Accessing
self.queue.queueis 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