remove run_in_loop function

This commit is contained in:
Izalia Mae 2022-11-07 05:40:08 -05:00
parent c66f9d34b3
commit 70e4870ba9
2 changed files with 6 additions and 10 deletions

View file

@ -76,7 +76,7 @@ def cli_inbox_follow(actor):
if database.get_inbox(actor):
return click.echo(f'Error: Already following actor: {actor}')
actor_data = run_in_loop(misc.request, actor, sign_headers=True)
actor_data = asyncio.run(misc.request(actor, sign_headers=True))
if not actor_data:
return click.echo(f'Error: Failed to fetch actor: {actor}')
@ -84,7 +84,7 @@ def cli_inbox_follow(actor):
database.add_inbox(actor_data.shared_inbox)
database.save()
run_in_loop(misc.follow_remote_actor, actor)
asyncio.run(misc.follow_remote_actor(actor))
click.echo(f'Sent follow message to actor: {actor}')
@ -100,7 +100,7 @@ def cli_inbox_unfollow(actor):
if database.del_inbox(actor):
database.save()
run_in_loop(misc.unfollow_remote_actor, actor)
asyncio.run(misc.unfollow_remote_actor(actor))
return click.echo(f'Sent unfollow message to: {actor}')
return click.echo(f'Error: Not following actor: {actor}')
@ -236,7 +236,7 @@ def cli_software_ban(name, fetch_nodeinfo):
return click.echo('Banned all relay software')
if fetch_nodeinfo:
software = run_in_loop(fetch_nodeinfo, name)
software = asyncio.run(misc.fetch_nodeinfo(name))
if not software:
click.echo(f'Failed to fetch software name from domain: {name}')
@ -268,7 +268,7 @@ def cli_software_unban(name, fetch_nodeinfo):
return click.echo('Unbanned all relay software')
if fetch_nodeinfo:
software = run_in_loop(fetch_nodeinfo, name)
software = asyncio.run(misc.fetch_nodeinfo(name))
if not software:
click.echo(f'Failed to fetch software name from domain: {name}')
@ -401,11 +401,6 @@ def relay_run():
loop.run_forever()
def run_in_loop(func, *args, **kwargs):
loop = asyncio.new_event_loop()
return loop.run_until_complete(func(*args, **kwargs))
async def handle_start_webserver():
config = app['config']
runner = AppRunner(app, access_log_format='%{X-Forwarded-For}i "%r" %s %b "%{Referer}i" "%{User-Agent}i"')

View file

@ -140,6 +140,7 @@ async def fetch_nodeinfo(domain):
return False
## todo: remove follow_remote_actor and unfollow_remote_actor
async def follow_remote_actor(actor_uri):
config = app['config']