cpython-uasyncio: Remove as new-uasyncio is compatible with CPython.

pull/376/head
Jim Mussared 2020-03-20 10:12:05 +11:00
rodzic b4eeaae105
commit caf16675cf
5 zmienionych plików z 0 dodań i 170 usunięć

Wyświetl plik

@ -1,21 +0,0 @@
import uasyncio as asyncio
def run1():
for i in range(1):
print('Hello World')
yield from asyncio.sleep(2)
print("run1 finished")
def run2():
for i in range(3):
print('bar')
yield run1()
yield from asyncio.sleep(1)
import logging
logging.basicConfig(level=logging.INFO)
loop = asyncio.get_event_loop()
loop.create_task(run2())
loop.run_forever()

Wyświetl plik

@ -1,3 +0,0 @@
srctype = cpython-backport
type = module
version = 0.2.1

Wyświetl plik

@ -1,27 +0,0 @@
This patch shows changes done to asyncio.tasks.Task._step() from CPython 3.4.2.
--- tasks.py 2015-01-01 10:51:40.707114866 +0200
+++ uasyncio.py 2015-01-01 10:54:20.172402890 +0200
@@ -46,13 +55,16 @@
# Bare yield relinquishes control for one event loop iteration.
self._loop.call_soon(self._step)
elif inspect.isgenerator(result):
+ #print("Scheduling", result)
+ self._loop.create_task(result)
+ self._loop.call_soon(self._step)
# Yielding a generator is just wrong.
- self._loop.call_soon(
- self._step, None,
- RuntimeError(
- 'yield was used instead of yield from for '
- 'generator in task {!r} with {}'.format(
- self, result)))
+# self._loop.call_soon(
+# self._step, None,
+# RuntimeError(
+# 'yield was used instead of yield from for '
+# 'generator in task {!r} with {}'.format(
+# self, result)))
else:
# Yielding something else is an error.
self._loop.call_soon(

Wyświetl plik

@ -1,20 +0,0 @@
import sys
# Remove current dir from sys.path, otherwise setuptools will peek up our
# module instead of system's.
sys.path.pop(0)
from setuptools import setup
sys.path.append("..")
import sdist_upip
setup(name='micropython-cpython-uasyncio',
version='0.2.1',
description='MicroPython module uasyncio ported to CPython',
long_description='This is MicroPython compatibility module, allowing applications using\nMicroPython-specific features to run on CPython.\n',
url='https://github.com/micropython/micropython-lib',
author='micropython-lib Developers',
author_email='micro-python@googlegroups.com',
maintainer='micropython-lib Developers',
maintainer_email='micro-python@googlegroups.com',
license='Python',
cmdclass={'sdist': sdist_upip.sdist},
py_modules=['uasyncio'])

Wyświetl plik

@ -1,99 +0,0 @@
import inspect
import asyncio
import asyncio.futures as futures
from asyncio import *
OrgTask = Task
class Task(OrgTask):
def _step(self, value=None, exc=None):
assert not self.done(), \
'_step(): already done: {!r}, {!r}, {!r}'.format(self, value, exc)
if self._must_cancel:
if not isinstance(exc, futures.CancelledError):
exc = futures.CancelledError()
self._must_cancel = False
coro = self._coro
self._fut_waiter = None
self.__class__._current_tasks[self._loop] = self
# Call either coro.throw(exc) or coro.send(value).
try:
if exc is not None:
result = coro.throw(exc)
elif value is not None:
result = coro.send(value)
else:
result = next(coro)
except StopIteration as exc:
self.set_result(exc.value)
except futures.CancelledError as exc:
super().cancel() # I.e., Future.cancel(self).
except Exception as exc:
self.set_exception(exc)
except BaseException as exc:
self.set_exception(exc)
raise
else:
if isinstance(result, futures.Future):
# Yielded Future must come from Future.__iter__().
if result._blocking:
result._blocking = False
result.add_done_callback(self._wakeup)
self._fut_waiter = result
if self._must_cancel:
if self._fut_waiter.cancel():
self._must_cancel = False
else:
self._loop.call_soon(
self._step, None,
RuntimeError(
'yield was used instead of yield from '
'in task {!r} with {!r}'.format(self, result)))
elif result is None:
# Bare yield relinquishes control for one event loop iteration.
self._loop.call_soon(self._step)
elif inspect.isgenerator(result):
#print("Scheduling", result)
self._loop.create_task(result)
self._loop.call_soon(self._step)
# Yielding a generator is just wrong.
# self._loop.call_soon(
# self._step, None,
# RuntimeError(
# 'yield was used instead of yield from for '
# 'generator in task {!r} with {}'.format(
# self, result)))
else:
# Yielding something else is an error.
self._loop.call_soon(
self._step, None,
RuntimeError(
'Task got bad yield: {!r}'.format(result)))
finally:
self.__class__._current_tasks.pop(self._loop)
self = None # Needed to break cycles when an exception occurs.
asyncio.tasks.Task = Task
OrgStreamWriter = StreamWriter
class StreamWriter(OrgStreamWriter):
def awrite(self, data):
if isinstance(data, str):
data = data.encode("utf-8")
self.write(data)
yield from self.drain()
def aclose(self):
self.close()
return
yield
asyncio.streams.StreamWriter = StreamWriter