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
Add params and type hints to stop() #6075 #6087
Add params and type hints to stop() #6075 #6087
Conversation
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.
I think your choosing to use variadic arguments is reasonable.
This change should be applied to all daemons and not just the Conveyor Preparer. In addition, I think it’s a good opportunity to add some type hints, given that they are trivial.
On looking into other stop functions, I saw that they had parameters |
806d676
to
534bdcf
Compare
I have changed the arguments of the stop functions of other daemons to |
I was surprised to see that so many
|
I prefer the second; |
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.
Be sure to import Optional
and FrameType
. Frequently we do it like so:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from types import FrameType
from typing import Optional
And then place the type hints inside strings.
Please note that the commits should be squashed together. Finally, the commit message has some room for improvement.
13c5e47
to
863e73a
Compare
I have imported the Types and I have fixed imports in several files and squashed the commit. Please review the commit message. Should I make it more descriptive? |
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.
And then place the type hints inside strings.
You missed this part. Type hints are evaluated and will lead to NameError
exceptions if the necessary classes are not imported at runtime.
As for the commit message:
- It should follow the format
<component>: <change_message> #<issue number>
. You did well, but since you are touching multiple components, you should omit the first part (as opposed to prefixing the message with ‘bug’). - The rest of the message can be misleading. ‘add default arguments’ suggests that the parameters already exist, which is not the case. As such, ‘add parameters’ is more appropriate.
- The body of the message is empty. You should use it to document why you are making this change. Explain how this is the proper signature for signal handlers and how deviating from it can lead to a
TypeError
.
a230a92
to
be6e646
Compare
c2baa16
to
38f24e0
Compare
I have updated my patch against the latest master branch and amended my commit message accordingly. Please review my changes 😄 |
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.
Please review the failed tests. It would appear that there are some missing imports.
For example:
lib/rucio/daemons/conveyor/preparer.py:42:49: F821 undefined name 'FrameType'
Similarly, in some places you moved the import statement under a conditional block (i.e. if TYPE_CHECKING
) for things that are already in use.
Finally, you’ll need to rebase your branch on the latest master.
1adac48
to
716717a
Compare
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.
This is likely to be my last request for changes. Please adjust some of the imports as noted in the comments below.
In addition, I would like to ask you to adjust the commit message. Please ensure that there is a blank line between the subject and the rest of the message, then move ‘Fixes #6075’ to the end of the subject.
lib/rucio/daemons/replicarecoverer/suspicious_replica_recoverer.py
Outdated
Show resolved
Hide resolved
716717a
to
6b367d7
Compare
6b367d7
to
fbc8bdb
Compare
The stop() functions used by daemons to gracefully stop had missing parameters `signum` and `frame`. These parameters are passed when the daemon receives SIGTERM signal. Since we have no use for the parameter as of now, we have set them to `None` by default. Also type-hints are added to the parameters and to the return type. Signed-off-by: Soumik Dutta <shalearkane@gmail.com>
fbc8bdb
to
8ef7361
Compare
Sir, could you please review the changes? I have made all the requested changes and have rebased the code against master branch. |
Fixes issue #6075
Overview
rucio/lib/rucio/daemons/conveyor/preparer.py
Lines 42 to 47 in f9d52b7
signalnum
andhandler
before being used as as signal handler inrucio/bin/rucio-conveyor-preparer
Lines 23 to 28 in f9d52b7
rucio/bin/rucio-conveyor-preparer
Line 28 in f9d52b7
*args
to the function parameters to resolve the issue.Alternative Solution
The other possible solution is to add the parameters:
However, then for the function call in Line 28,
rucio/bin/rucio-conveyor-preparer
Line 28 in f9d52b7
stop()
.