Skip to content

Commit

Permalink
Fixed errors due to missing _thread_id in Python 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Sep 5, 2015
1 parent 4c5b98f commit d3ada10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions asphalt/core/application.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from concurrent.futures import ThreadPoolExecutor
import threading
from typing import Dict, Any, Union
from logging import getLogger
import logging.config
Expand Down Expand Up @@ -89,6 +90,7 @@ def run(self):

# This is necessary to make @asynchronous work
util.event_loop = asyncio.get_event_loop()
util.event_loop_thread_id = threading.get_ident()

# Assign a new default executor with the given max worker thread limit
event_loop = asyncio.get_event_loop()
Expand Down
6 changes: 3 additions & 3 deletions asphalt/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
__all__ = ('resolve_reference', 'qualified_name', 'synchronous', 'asynchronous',
'wrap_blocking_api', 'wrap_async_api')

event_loop = None
event_loop = event_loop_thread_id = None


def resolve_reference(ref):
Expand Down Expand Up @@ -66,7 +66,7 @@ def synchronous(func: Callable[..., Any]):

@wraps(func, updated=())
def wrapper(*args, **kwargs):
if get_ident() == event_loop._thread_id:
if get_ident() == event_loop_thread_id:
callback = partial(func, *args, **kwargs)
return event_loop.run_in_executor(None, callback)
else:
Expand Down Expand Up @@ -99,7 +99,7 @@ def callback():
else:
f.set_result(retval)

if event_loop._thread_id in (get_ident(), None):
if event_loop_thread_id in (get_ident(), None):
return func(*args, **kwargs)
else:
f = Future()
Expand Down

0 comments on commit d3ada10

Please sign in to comment.