Skip to content

Commit 36f6a22

Browse files
committed
Simplify retrieval of help message and prevent thread-unsafe behavior
The `print_help` method from the `argparse` module was previously used, followed by a thread-unsafe redirect of stdout. This was removed and replaced with the use of the `format_help` method, which outputs a string containing the needed help message in a much better way.
1 parent 750e207 commit 36f6a22

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

packit_service/worker/handlers/forges.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
TODO: The build and test handlers are independent and should be moved away.
77
"""
88

9-
# import io
109
import logging
1110

12-
# import sys
1311
from packit.config import (
1412
Deployment,
1513
JobConfig,
@@ -343,14 +341,7 @@ def run(self) -> TaskResults:
343341
# epilog=HELP_COMMENT_EPILOG,
344342
# )
345343

346-
# # prevent help message from being printed to stdout
347-
# # save help message to buffer
348-
# help_message_buffer = io.StringIO()
349-
# backup_stdout = sys.stdout
350-
# sys.stdout = help_message_buffer
351-
# parser.print_help()
352-
# sys.stdout = backup_stdout
353-
# help_message = help_message_buffer.getvalue()
344+
# help_message = parser.format_help()
354345

355346
self.pr.comment(body=help_message)
356347
return TaskResults(success=True, details={"msg": help_message})

0 commit comments

Comments
 (0)