Skip to content

Commit

Permalink
Merge d62d691 into 41a14ca
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed May 6, 2019
2 parents 41a14ca + d62d691 commit 6ef935a
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 64 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,9 @@ Ideally, within a virtual environment.

Changelog
=========
### 2.5.1 - TBD
- Optimizations and simplification of async support, taking advantadge of Python3.4 deprecation.

### 2.5.0 - May 4, 2019
- Updated to latest Falcon: 2.0.0
- Added support for Marshmallow 3
Expand Down
57 changes: 0 additions & 57 deletions hug/_async.py

This file was deleted.

2 changes: 1 addition & 1 deletion hug/api.py
Expand Up @@ -21,6 +21,7 @@
"""
from __future__ import absolute_import

import asyncio
import sys
from collections import OrderedDict, namedtuple
from distutils.util import strtobool
Expand All @@ -35,7 +36,6 @@
import hug.defaults
import hug.output_format
from hug import introspect
from hug._async import asyncio, ensure_future
from hug._version import current

INTRO = """
Expand Down
12 changes: 11 additions & 1 deletion hug/interface.py
Expand Up @@ -22,6 +22,7 @@
from __future__ import absolute_import

import argparse
import asyncio
import os
import sys
from collections import OrderedDict
Expand All @@ -35,12 +36,21 @@
import hug.output_format
import hug.types as types
from hug import introspect
from hug._async import asyncio_call
from hug.exceptions import InvalidTypeData
from hug.format import parse_content_type
from hug.types import MarshmallowInputSchema, MarshmallowReturnSchema, Multiple, OneOf, SmartBoolean, Text, text


def asyncio_call(function, *args, **kwargs):
loop = asyncio.get_event_loop()
if loop.is_running():
return function(*args, **kwargs)

function = asyncio.ensure_future(function(*args, **kwargs), loop=loop)
loop.run_until_complete(function)
return function.result()


class Interfaces(object):
"""Defines the per-function singleton applied to hugged functions defining common data needed by all interfaces"""

Expand Down
2 changes: 1 addition & 1 deletion hug/test.py
Expand Up @@ -29,7 +29,7 @@
from urllib.parse import urlencode

from falcon import HTTP_METHODS
from falcon.testing import StartResponseMock, create_environ, DEFAULT_HOST
from falcon.testing import DEFAULT_HOST, StartResponseMock, create_environ

from hug import output_format
from hug.api import API
Expand Down
2 changes: 1 addition & 1 deletion requirements/development.txt
Expand Up @@ -3,7 +3,7 @@ Cython==0.29.6
-r common.txt
flake8==3.5.0
ipython==6.2.1
isort==4.2.5
isort==4.3.18
pytest-cov==2.5.1
pytest==4.3.1
python-coveralls==2.9.1
Expand Down
4 changes: 2 additions & 2 deletions tests/test_decorators.py
Expand Up @@ -19,6 +19,7 @@
OTHER DEALINGS IN THE SOFTWARE.
"""
import asyncio
import json
import os
import sys
Expand All @@ -33,7 +34,6 @@
from marshmallow import ValidationError

import hug
from hug._async import coroutine
from hug.exceptions import InvalidTypeData

from .constants import BASE_DIRECTORY
Expand Down Expand Up @@ -1476,7 +1476,7 @@ def happens_on_startup(api):
pass

@hug.startup()
@coroutine
@asyncio.coroutine
def async_happens_on_startup(api):
pass

Expand Down
2 changes: 1 addition & 1 deletion tests/test_types.py
Expand Up @@ -26,7 +26,7 @@
from uuid import UUID

import pytest
from marshmallow import Schema, fields, ValidationError
from marshmallow import Schema, ValidationError, fields
from marshmallow.decorators import validates_schema

import hug
Expand Down

0 comments on commit 6ef935a

Please sign in to comment.