Skip to content

Commit

Permalink
async fixes 5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
divi255 committed Aug 4, 2021
1 parent 0430931 commit 4110231
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 7 additions & 6 deletions pptop/plugins/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ def injection_load(l=None, **kwargs):

def injection(cmd=None, loop=None):

import asyncio
if hasattr(asyncio, 'all_tasks'):
all_tasks_fn = 'asyncio.all_tasks'
else:
all_tasks_fn = 'asyncio.Task.all_tasks'

def parse_loop(loop):
try:
if loop[loop.find(':') + 1] == ':':
Expand Down Expand Up @@ -176,14 +182,9 @@ def parse_loop(loop):
loop = v[1]
loop_name = '{}::{}'.format(mod, loop)
try:
import asyncio
if hasattr(asyncio, 'all_tasks'):
fn = 'asyncio.all_tasks'
else:
fn = 'asyncio.Task.all_tasks'
ge = {}
src = ('import {mod}; import asyncio;' +
'out=list({fn}(loop={mod}.{loop}))').format(fn=fn,
'out=list({fn}(loop={mod}.{loop}))').format(fn=all_tasks_fn,
mod=mod,
loop=loop)
exec(src, ge)
Expand Down
7 changes: 6 additions & 1 deletion pptop/plugins/neotasker.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ def injection_load(task_supervisor=None, **kwargs):

def injection(cmd=None):
result = []
import asyncio
try:
all_tasks = asyncio.Task.all_tasks
except:
all_tasks = asyncio.all_tasks
if cmd == 'loops':
import linecache
import asyncio
Expand All @@ -201,7 +206,7 @@ def injection(cmd=None):
loops.add((i, l))
for loop_name, loop in loops:
try:
for l in asyncio.Task.all_tasks(loop=loop):
for l in all_tasks(loop=loop):
coro = ''
fname = ''
isl = str(l).split()
Expand Down

0 comments on commit 4110231

Please sign in to comment.