Skip to content

Commit

Permalink
Use uvloop for reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Mar 30, 2020
1 parent 7a76296 commit ee1fdae
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ force_sort_within_sections=True
line_length=120
known_future_library=future
known_first_party=tribler_core,tribler_gui,tribler_common,run_tribler
known_third_party=pony,twisted,six,anydex,ipv8,libtorrent,lz4,PyQt5,zope,aiohttp,psutil,configobj,ipv8_service,asynctest,numpy,networkx,async_timeout,cherrypy,nose,validate,check_os,matplotlib,pyqtgraph,_socket
known_third_party=pony,twisted,six,anydex,ipv8,libtorrent,lz4,PyQt5,zope,aiohttp,psutil,configobj,ipv8_service,asynctest,numpy,networkx,async_timeout,cherrypy,nose,validate,check_os,matplotlib,pyqtgraph,_socket,uvloop
3 changes: 2 additions & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ cryptography
aiohttp
aiohttp_apispec
faulthandler
pyyaml
pyyaml
uvloop
2 changes: 2 additions & 0 deletions src/run_tribler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ async def start_tribler():
await session.start()

logging.getLogger('asyncio').setLevel(logging.WARNING)
import uvloop
uvloop.install()
get_event_loop().create_task(start_tribler())
get_event_loop().run_forever()

Expand Down
9 changes: 6 additions & 3 deletions src/tribler-core/run_market_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def signal_handler(sig):
config.set_http_api_enabled(True)
config.set_http_api_port(options.restapi)

if options.ipv8 != -1 and options.ipv8 > 0:
if options.ipv8 > 0:
config.set_ipv8_port(options.ipv8)

if options.testnet:
Expand All @@ -79,13 +79,16 @@ def main(argv):
parser.add_argument('--help', '-h', action='help', default=argparse.SUPPRESS, help='Show this help message and exit')
parser.add_argument('--statedir', '-s', default=None, help='Use an alternate statedir')
parser.add_argument('--restapi', '-p', default=-1, type=int, help='Use an alternate port for REST API')
parser.add_argument('--ipv8', '-i', default=8085, type=int, help='Use an alternate port for the IPv8')
parser.add_argument('--ipv8', '-i', default=-1, type=int, help='Use an alternate port for the IPv8')

parser.add_argument('--testnet', '-t', action='store_const', default=False, const=True, help='Join the testnet')

args = parser.parse_args(sys.argv[1:])
service = MarketService()


import uvloop
uvloop.install()

loop = get_event_loop()
coro = service.start_tribler(args)
ensure_future(coro)
Expand Down
5 changes: 4 additions & 1 deletion src/tribler-core/run_tribler_headless.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def main(argv):
help='Show this help message and exit')
parser.add_argument('--statedir', '-s', default=None, help='Use an alternate statedir')
parser.add_argument('--restapi', '-p', default=-1, type=int, help='Use an alternate port for REST API')
parser.add_argument('--ipv8', '-i', default=8085, type=int, help='Use an alternate port for the IPv8')
parser.add_argument('--ipv8', '-i', default=-1, type=int, help='Use an alternate port for the IPv8')
parser.add_argument('--libtorrent', '-l', default=-1, type=int, help='Use an alternate port for libtorrent')
parser.add_argument('--ipv8_bootstrap_override', '-b', default=None, type=str,
help='Force the usage of specific IPv8 bootstrap server (ip:port)', action=IPPortAction)
Expand All @@ -123,6 +123,9 @@ def main(argv):
args = parser.parse_args(sys.argv[1:])
service = TriblerService()

import uvloop
uvloop.install()

loop = get_event_loop()
coro = service.start_tribler(args)
ensure_future(coro)
Expand Down
3 changes: 3 additions & 0 deletions src/tribler-core/run_tunnel_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def main(argv):

args = parser.parse_args(sys.argv[1:])
service = TunnelHelperService()

import uvloop
uvloop.install()

loop = get_event_loop()
coro = service.start(args)
Expand Down
1 change: 1 addition & 0 deletions src/tribler-core/tribler_core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
{'module': 'pathlib', 'install_type': 'pip3', 'package': 'pathlib', 'optional': False, 'scope': 'core'},
{'module': 'bitcoinlib', 'install_type': 'pip3', 'package': 'bitcoinlib', 'optional': True, 'scope': 'core'},
{'module': 'PIL', 'install_type': 'pip3', 'package': 'PIL', 'optional': False, 'scope': 'gui'},
{'module': 'uvloop', 'install_type': 'pip3', 'package': 'uvloop', 'optional': False, 'scope': 'core'},
{'module': 'pyasn1', 'install_type': 'pip3', 'package': 'pyasn1', 'optional': False, 'scope': 'core'},
]

Expand Down
4 changes: 4 additions & 0 deletions src/tribler-core/tribler_core/tests/tools/test_as_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import asynctest

import uvloop

from tribler_common.simpledefs import DLSTATUS_SEEDING

from tribler_core.config.tribler_config import TriblerConfig
Expand All @@ -38,6 +40,8 @@
OUTPUT_DIR = path_util.abspath(os.environ.get('OUTPUT_DIR', 'output'))


uvloop.install()

class BaseTestCase(asynctest.TestCase):

def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit ee1fdae

Please sign in to comment.