-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from noisyboiler/remove-async-ref-as-now-a-key…
…word Remove async ref as now a keyword. Drop Python3.3.
- Loading branch information
Showing
14 changed files
with
112 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ sudo: false | |
|
||
python: | ||
- "2.7" | ||
- "3.3" | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
from wampy.config.defaults import async_name | ||
from wampy.constants import EVENTLET, GEVENT | ||
from wampy.errors import WampyError | ||
|
||
|
||
def get_async_adapter(): | ||
if async_name == GEVENT: | ||
from . gevent_ import Gevent | ||
_adapter = Gevent() | ||
return _adapter | ||
|
||
if async_name == EVENTLET: | ||
from . eventlet_ import Eventlet | ||
_adapter = Eventlet() | ||
return _adapter | ||
|
||
raise WampyError( | ||
'only gevent and eventlet are supported, sorry. help out??' | ||
) | ||
|
||
|
||
async_adapter = get_async_adapter() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import eventlet | ||
|
||
from wampy.errors import WampProtocolError | ||
from wampy.interfaces import Async | ||
|
||
|
||
class Eventlet(Async): | ||
|
||
def __init__(self): | ||
self.message_queue = eventlet.Queue() | ||
|
||
def Timeout(self, timeout): | ||
return eventlet.Timeout(timeout) | ||
|
||
def receive_message(self, timeout): | ||
try: | ||
message = self._wait_for_message(timeout) | ||
except eventlet.Timeout: | ||
raise WampProtocolError( | ||
"no message returned (timed-out in {})".format(timeout) | ||
) | ||
return message | ||
|
||
def spawn(self, *args, **kwargs): | ||
gthread = eventlet.spawn(*args, **kwargs) | ||
return gthread | ||
|
||
def sleep(self, time): | ||
return eventlet.sleep(time) | ||
|
||
def _wait_for_message(self, timeout): | ||
q = self.message_queue | ||
|
||
with eventlet.Timeout(timeout): | ||
while q.qsize() == 0: | ||
eventlet.sleep() | ||
|
||
message = q.get() | ||
return message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import gevent | ||
import gevent.queue | ||
import gevent.monkey | ||
|
||
from wampy.errors import WampProtocolError | ||
from wampy.interfaces import Async | ||
|
||
|
||
class Gevent(Async): | ||
|
||
def __init__(self): | ||
self.message_queue = gevent.queue.Queue() | ||
|
||
def Timeout(self, timeout): | ||
return gevent.Timeout(timeout) | ||
|
||
def receive_message(self, timeout): | ||
try: | ||
message = self.message_queue.get(timeout=timeout) | ||
except gevent.queue.Empty: | ||
raise WampProtocolError( | ||
"no message returned (timed-out in {})".format(timeout) | ||
) | ||
return message | ||
|
||
def spawn(self, *args, **kwargs): | ||
gthread = gevent.spawn(*args, **kwargs) | ||
return gthread | ||
|
||
def sleep(self, time): | ||
return gevent.sleep(time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters