All of scrython now uses threading.

This commit is contained in:
2018-02-28 21:34:39 -05:00
parent a40d85419d
commit c9dd5d7724
4 changed files with 32 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import aiohttp import aiohttp
import urllib.parse import urllib.parse
from threading import Thread
class CatalogsObject(object): class CatalogsObject(object):
""" """
@ -33,9 +34,14 @@ class CatalogsObject(object):
async with aiohttp.ClientSession(loop=loop) as client: async with aiohttp.ClientSession(loop=loop) as client:
self.scryfallJson = await getRequest(client, self._url) self.scryfallJson = await getRequest(client, self._url)
loop = asyncio.get_event_loop() def do_everything():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main(loop)) loop.run_until_complete(main(loop))
t = Thread(target=do_everything)
t.run()
if self.scryfallJson['object'] == 'error': if self.scryfallJson['object'] == 'error':
raise Exception(self.scryfallJson['details']) raise Exception(self.scryfallJson['details'])

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import aiohttp import aiohttp
import urllib.parse import urllib.parse
from threading import Thread
class RulingsObject(object): class RulingsObject(object):
""" """
@ -47,9 +48,14 @@ class RulingsObject(object):
async with aiohttp.ClientSession(loop=loop) as client: async with aiohttp.ClientSession(loop=loop) as client:
self.scryfallJson = await getRequest(client, self._url) self.scryfallJson = await getRequest(client, self._url)
loop = asyncio.get_event_loop() def do_everything():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main(loop)) loop.run_until_complete(main(loop))
t = Thread(target=do_everything)
t.run()
if self.scryfallJson['object'] == 'error': if self.scryfallJson['object'] == 'error':
raise Exception(self.scryfallJson['details']) raise Exception(self.scryfallJson['details'])

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import aiohttp import aiohttp
import urllib.parse import urllib.parse
from threading import Thread
class SetsObject(object): class SetsObject(object):
""" """
@ -43,9 +44,14 @@ class SetsObject(object):
async with aiohttp.ClientSession(loop=loop) as client: async with aiohttp.ClientSession(loop=loop) as client:
self.scryfallJson = await getRequest(client, self._url) self.scryfallJson = await getRequest(client, self._url)
loop = asyncio.get_event_loop() def do_everything():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main(loop)) loop.run_until_complete(main(loop))
t = Thread(target=do_everything)
t.run()
if self.scryfallJson['object'] == 'error': if self.scryfallJson['object'] == 'error':
raise Exception(self.scryfallJson['details']) raise Exception(self.scryfallJson['details'])

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import aiohttp import aiohttp
import urllib.parse import urllib.parse
from threading import Thread
class SymbologyObject(object): class SymbologyObject(object):
""" """
@ -30,8 +31,13 @@ class SymbologyObject(object):
async with aiohttp.ClientSession(loop=loop) as client: async with aiohttp.ClientSession(loop=loop) as client:
self.scryfallJson = await getRequest(client, self._url) self.scryfallJson = await getRequest(client, self._url)
loop = asyncio.get_event_loop() def do_everything():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main(loop)) loop.run_until_complete(main(loop))
t = Thread(target=do_everything)
t.run()
if self.scryfallJson['object'] == 'error': if self.scryfallJson['object'] == 'error':
raise Exception(self.scryfallJson['details']) raise Exception(self.scryfallJson['details'])