Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/click-8.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-mukhin authored Apr 29, 2024
2 parents fc1b443 + 516f5e0 commit e9b5dd0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
27 changes: 21 additions & 6 deletions migro/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,35 @@
from migro.filestack.utils import build_url


async def ask_exit(event_loop):
async def ask_exit():
"""Loop and tasks shutdown callback."""
tasks = [t for t in asyncio.Task.all_tasks(event_loop) if t is not
asyncio.Task.current_task()]

# Handling tasks differently based on Python version due to the deprecation
# of asyncio.Task.all_tasks() and asyncio.Task.current_task() in favor of
# asyncio.all_tasks() and asyncio.current_task() without the need for the event loop.
if sys.version_info < (3, 7):
tasks = [t for t in asyncio.Task.all_tasks() if t is not
asyncio.Task.current_task()]
else:
tasks = [t for t in asyncio.all_tasks() if t is not
asyncio.current_task()]

[task.cancel() for task in tasks]
await asyncio.gather(*tasks)
event_loop.stop()

if sys.version_info < (3, 7):
await asyncio.gather(*tasks)
else:
await asyncio.gather(*tasks, return_exceptions=True)

running_loop = asyncio.get_running_loop() if sys.version_info >= (3, 7) else asyncio.get_event_loop()
running_loop.stop()


try:
signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT)
for s in signals:
loop.add_signal_handler(
s, lambda: asyncio.ensure_future(ask_exit(loop))
s, lambda: asyncio.ensure_future(ask_exit())
)
except NotImplementedError:
if not sys.platform.startswith('win'):
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
aiohttp==3.8.4
aiohttp==3.9.2
click==8.1.7
python-dateutil==2.8.2
tqdm==4.65.0
colorama==0.4.6
tqdm==4.66.1
colorama==0.4.6
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
},
zip_safe=False,
install_requires=[
'aiohttp==3.8.4',
'aiohttp==3.9.2',
'click==8.1.7',
'click==8.1.3',
'python-dateutil==2.8.2',
'tqdm==4.65.0',
'tqdm==4.66.1',
'colorama==0.4.6',
],
include_package_data=True,
Expand Down

0 comments on commit e9b5dd0

Please sign in to comment.