New Upstream Snapshot - pyserial-asyncio

Ready changes

Summary

Merged new upstream version: 0.6+git20221030.2.13694c5 (was: 0.6+git20221030.1.13694c5).

Resulting package

Built on 2022-12-18T17:53 (took 5m34s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots python-serial-asyncio-docapt install -t fresh-snapshots python3-serial-asyncio

Lintian Result

Diff

diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml
deleted file mode 100644
index 561ab2f..0000000
--- a/.github/workflows/build-package.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-# create wheel file
-
-name: build Python package
-
-on:
-  push:
-    branches: [ master ]
-
-jobs:
-  build:
-    name: Build Wheel
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-    - name: Set up Python
-      uses: actions/setup-python@v2
-      with:
-        python-version: '3.x'
-    - name: Install build dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install setuptools wheel
-    - name: Build package
-      run: |
-        python setup.py sdist bdist_wheel
-    - name: Upload Artifacts
-      uses: actions/upload-artifact@v2
-      with:
-        path: |
-          dist/*.whl
-          dist/*.tar.gz
diff --git a/.github/workflows/release-to-pypi.yml b/.github/workflows/release-to-pypi.yml
deleted file mode 100644
index 0eb1fe7..0000000
--- a/.github/workflows/release-to-pypi.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-# upload source and wheel from build action
-
-name: Upload Python Package
-
-on:
-  release:
-    types: [created]
-
-jobs:
-  deploy:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-    - name: Set up Python
-      uses: actions/setup-python@v2
-      with:
-        python-version: '3.x'
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install setuptools wheel twine
-    - name: Build
-      run: |
-        python setup.py sdist bdist_wheel
-    - name: Upload Artifacts
-      uses: actions/upload-artifact@v2
-      with:
-        path: |
-          dist/*.whl
-          dist/*.tar.gz
-    - name: Publish to PyPi
-      env:
-        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
-        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
-      run: |
-        twine upload dist/*
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index fb44ebb..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-**/__pycache__
-*.pyc
-*.pyo
-documentation/_build
-build
-dist
-*.egg-info
-
-/MANIFEST
-
-.idea
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 2c264fd..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-# (C) 2016 Chris Liechti <cliechti@gmx.net>
-# SPDX-License-Identifier:    BSD-3-Clause
-
-language: python
-cache: pip
-
-python:
-  - 3.5
-  - 3.6
-  - 3.7
-  - 3.8
-
-install:
-  - pip install -r requirements-travis.txt
-  - pip install -e .
-
-script:
-  - python test/test_asyncio.py
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
deleted file mode 100644
index a84b76d..0000000
--- a/CONTRIBUTING.rst
+++ /dev/null
@@ -1,46 +0,0 @@
-==============
- Contributing
-==============
-
-How Can I Contribute?
-=====================
-
-Reporting Bugs and Suggesting Enhancements
-    The easiest is creating an issue_. You can do that for ideas or problems.
-
-    For bugs, if possible, try to construct a small code example that exhibits
-    the problem. Include version numbers (Python, pySerial,
-    pySerial-asyncio).
-
-Pull Requests
-    Code / test / documentation contributions are of course welcome_!
-
-    Consider that this is a project that aims to run on many platforms and
-    architectures and therefore needs implementations covering all of them, of
-    course there are exceptions and starting on one platform is better than
-    starting on none.
-
-    When providing new features, also think of documentation and tests if
-    possible.
-
-
-Ownership
-=========
-
-- By contributing to this project, you agree that the material is labeled as
-  "copyright by pySerial-team". Names or handles of individual contributors are
-  listed in a separate file: CREDITS.rst_.
-
-- Your contribution may be used in its original or modified form.
-
-- The project maintainer(s) can make decisions in the name of
-  the pySerial-team. Including but not limited to:
-
-  - making releases, adding/removing features, changing the design, etc.
-  - adding or removing project maintainers
-  - license changes, as long as it remains a permissive open source license.
-
-
-.. _CREDITS.rst: CREDITS.rst
-.. _issue: https://github.com/pyserial/pyserial-asyncio/issues
-.. _welcome: https://github.com/pyserial/pyserial-asyncio/pulls
diff --git a/DEVELOPER.rst b/DEVELOPER.rst
deleted file mode 100644
index 3c2ec4c..0000000
--- a/DEVELOPER.rst
+++ /dev/null
@@ -1,16 +0,0 @@
-====================
-Notes for developers
-====================
-
-Creating a release
-==================
-
-- Ensure that the ``version`` in ``serial_asyncio/__init__.py`` is updated
-  and in the form of major.minor[.patchlevel]
-- Ensure all changes, including version, is committed then create a tag with
-  the same value as the version but prefixed with a ``v`` (e.g. "v0.5")
-- Push to GitHub, merge into master if it is a branch. The GitHub Actions
-  are set-up to build the default branch.
-- Inspect the built wheel and tar.gz files for correctness, test.
-- Trigger the upload to PyPi by using GitHub web interface "Releases" and
-  create a new release from the tag.
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..a387467
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,31 @@
+Metadata-Version: 2.1
+Name: pyserial-asyncio
+Version: 0.6
+Summary: Python Serial Port Extension - Asynchronous I/O support
+Home-page: https://github.com/pyserial/pyserial-asyncio
+Author: pySerial-team
+License: BSD
+Platform: any
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: End Users/Desktop
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Natural Language :: English
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Topic :: Communications
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Terminals :: Serial
+License-File: LICENSE.txt
+
+Async I/O extension package for the Python Serial Port Extension for OSX, Linux, BSD
+
+- Documentation: http://pyserial-asyncio.readthedocs.io
+- Project Homepage: https://github.com/pyserial/pyserial-asyncio
diff --git a/debian/changelog b/debian/changelog
index c90e269..b7109f6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+pyserial-asyncio (0.6+git20221030.2.13694c5-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sun, 18 Dec 2022 17:49:18 -0000
+
 pyserial-asyncio (0.6-4) unstable; urgency=medium
 
   * Add patch: Use free port for test (Closes: #1023019)
diff --git a/debian/patches/use-free-port-for-test.patch b/debian/patches/use-free-port-for-test.patch
index 3b3259f..d1fc1f3 100644
--- a/debian/patches/use-free-port-for-test.patch
+++ b/debian/patches/use-free-port-for-test.patch
@@ -5,9 +5,11 @@ Bug-Debian: https://bugs.debian.org/1023019
 Last-Update: 2022-11-02
 ---
 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/test/test_asyncio.py
-+++ b/test/test_asyncio.py
-@@ -21,8 +21,17 @@
+Index: pyserial-asyncio.git/test/test_asyncio.py
+===================================================================
+--- pyserial-asyncio.git.orig/test/test_asyncio.py
++++ pyserial-asyncio.git/test/test_asyncio.py
+@@ -21,8 +21,17 @@ import asyncio
  
  import serial_asyncio
  
diff --git a/documentation/index.rst b/documentation/index.rst
index 8f4e727..1645f84 100644
--- a/documentation/index.rst
+++ b/documentation/index.rst
@@ -3,7 +3,9 @@
 Welcome to pySerial-asyncio's documentation
 ===========================================
 
-`Async I/O`_ extension for the `Python Serial Port`_ package for OSX, Linux, BSD
+`Async I/O`_ extension for the `Python Serial Port`_ package for OSX, Linux, BSD.
+Support for Windows is included, though with a different implementation based on polling
+which may be slower than on other platforms.
 
 It depends on pySerial and is compatible with Python 3.5 and later.
 
diff --git a/documentation/shortintro.rst b/documentation/shortintro.rst
index b4cc684..869de9f 100644
--- a/documentation/shortintro.rst
+++ b/documentation/shortintro.rst
@@ -87,3 +87,43 @@ port asynchronously::
     loop.run_forever()
     loop.close()
 
+Reading data in chunks
+----------------------
+
+This example will read chunks from the serial port every 300ms::
+
+
+    import asyncio
+    import serial_asyncio
+    
+    
+    class InputChunkProtocol(asyncio.Protocol):
+        def connection_made(self, transport):
+            self.transport = transport
+        
+        def data_received(self, data):
+            print('data received', repr(data))
+            
+            # stop callbacks again immediately
+            self.pause_reading()
+                
+        def pause_reading(self):
+            # This will stop the callbacks to data_received
+            self.transport.pause_reading()
+                
+        def resume_reading(self):
+            # This will start the callbacks to data_received again with all data that has been received in the meantime.
+            self.transport.resume_reading()
+        
+    
+    async def reader():
+        transport, protocol = await serial_asyncio.create_serial_connection(loop, InputChunkProtocol, '/dev/ttyUSB0', baudrate=115200)
+    
+        while True:
+            await asyncio.sleep(0.3)
+            protocol.resume_reading()
+    
+    
+    loop = asyncio.get_event_loop()
+    loop.run_until_complete(reader())
+    loop.close()
diff --git a/pyserial_asyncio.egg-info/PKG-INFO b/pyserial_asyncio.egg-info/PKG-INFO
new file mode 100644
index 0000000..a387467
--- /dev/null
+++ b/pyserial_asyncio.egg-info/PKG-INFO
@@ -0,0 +1,31 @@
+Metadata-Version: 2.1
+Name: pyserial-asyncio
+Version: 0.6
+Summary: Python Serial Port Extension - Asynchronous I/O support
+Home-page: https://github.com/pyserial/pyserial-asyncio
+Author: pySerial-team
+License: BSD
+Platform: any
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: End Users/Desktop
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Natural Language :: English
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Topic :: Communications
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Terminals :: Serial
+License-File: LICENSE.txt
+
+Async I/O extension package for the Python Serial Port Extension for OSX, Linux, BSD
+
+- Documentation: http://pyserial-asyncio.readthedocs.io
+- Project Homepage: https://github.com/pyserial/pyserial-asyncio
diff --git a/pyserial_asyncio.egg-info/SOURCES.txt b/pyserial_asyncio.egg-info/SOURCES.txt
new file mode 100644
index 0000000..59cedad
--- /dev/null
+++ b/pyserial_asyncio.egg-info/SOURCES.txt
@@ -0,0 +1,22 @@
+CREDITS.rst
+LICENSE.txt
+MANIFEST.in
+README.rst
+requirements.txt
+setup.cfg
+setup.py
+documentation/Makefile
+documentation/api.rst
+documentation/appendix.rst
+documentation/conf.py
+documentation/index.rst
+documentation/pyserial-asyncio.png
+documentation/shortintro.rst
+pyserial_asyncio.egg-info/PKG-INFO
+pyserial_asyncio.egg-info/SOURCES.txt
+pyserial_asyncio.egg-info/dependency_links.txt
+pyserial_asyncio.egg-info/requires.txt
+pyserial_asyncio.egg-info/top_level.txt
+serial_asyncio/__init__.py
+test/__init__.py
+test/test_asyncio.py
\ No newline at end of file
diff --git a/pyserial_asyncio.egg-info/dependency_links.txt b/pyserial_asyncio.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/pyserial_asyncio.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/pyserial_asyncio.egg-info/requires.txt b/pyserial_asyncio.egg-info/requires.txt
new file mode 100644
index 0000000..f6c1a1f
--- /dev/null
+++ b/pyserial_asyncio.egg-info/requires.txt
@@ -0,0 +1 @@
+pyserial
diff --git a/pyserial_asyncio.egg-info/top_level.txt b/pyserial_asyncio.egg-info/top_level.txt
new file mode 100644
index 0000000..d97e4bb
--- /dev/null
+++ b/pyserial_asyncio.egg-info/top_level.txt
@@ -0,0 +1 @@
+serial_asyncio
diff --git a/requirements-travis.txt b/requirements-travis.txt
deleted file mode 100644
index be9a2d3..0000000
--- a/requirements-travis.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Depend on the head of pyserial
-git+https://github.com/pyserial/pyserial.git#egg=pyserial
-
-# OR
-
-# Depend on a specific pyserial commit
-# git+https://github.com/pyserial/pyserial.git@000b14389171a9f0d7d713466b32bc649b0bed8e#egg=pyserial
diff --git a/serial_asyncio/__init__.py b/serial_asyncio/__init__.py
index 168760c..e173b56 100644
--- a/serial_asyncio/__init__.py
+++ b/serial_asyncio/__init__.py
@@ -17,8 +17,10 @@ implementation. It should be possible to get that working though.
 """
 import asyncio
 import os
+import urllib.parse
 
 import serial
+from functools import partial
 
 try:
     import termios
@@ -379,7 +381,7 @@ class SerialTransport(asyncio.Transport):
         self._remove_reader()
         if self._flushed():
             self._remove_writer()
-            self._loop.call_soon(self._call_connection_lost, exc)
+            self._loop.create_task(self._call_connection_lost(exc))
 
     def _abort(self, exc):
         """Close the transport immediately.
@@ -393,9 +395,9 @@ class SerialTransport(asyncio.Transport):
         self._closing = True
         self._remove_reader()
         self._remove_writer()  # Pending buffered data will not be written
-        self._loop.call_soon(self._call_connection_lost, exc)
+        self._loop.create_task(self._call_connection_lost(exc))
 
-    def _call_connection_lost(self, exc):
+    async def _call_connection_lost(self, exc):
         """Close the connection.
 
         Informs the protocol through connection_lost() and clears
@@ -405,22 +407,23 @@ class SerialTransport(asyncio.Transport):
         assert not self._has_writer
         assert not self._has_reader
         try:
-            self._serial.flush()
+            await self._loop.run_in_executor(None, self._serial.flush)
         except (serial.SerialException if os.name == "nt" else termios.error):
             # ignore serial errors which may happen if the serial device was
             # hot-unplugged.
             pass
+
         try:
             self._protocol.connection_lost(exc)
         finally:
             self._write_buffer.clear()
-            self._serial.close()
+            await self._loop.run_in_executor(None, self._serial.close)
             self._serial = None
             self._protocol = None
             self._loop = None
 
 
-async def create_serial_connection(loop, protocol_factory, *args, **kwargs):
+async def create_serial_connection(loop, protocol_factory, url, *args, **kwargs):
     """Create a connection to a new serial port instance.
 
     This function is a coroutine which will try to establish the
@@ -445,8 +448,23 @@ async def create_serial_connection(loop, protocol_factory, *args, **kwargs):
 
     Any additional arguments will be forwarded to the Serial constructor.
     """
-    serial_instance = serial.serial_for_url(*args, **kwargs)
-    transport, protocol = await connection_for_serial(loop, protocol_factory, serial_instance)
+    parsed_url = urllib.parse.urlparse(url)
+
+    callback = partial(serial.serial_for_url, url, *args, **kwargs)
+    serial_instance = await loop.run_in_executor(None, callback)
+
+    if parsed_url.scheme == "socket":
+        transport, protocol = await loop.create_connection(protocol_factory, parsed_url.hostname, parsed_url.port)
+
+        # To maintain API compatibility
+        transport.flush = lambda: None
+        transport.loop = loop
+        transport.serial = serial_instance
+        transport._extra["serial"] = serial_instance
+        serial_instance._socket = transport.get_extra_info("socket")._sock
+    else:
+        transport, protocol = await connection_for_serial(loop, protocol_factory, serial_instance)
+
     return transport, protocol
 
 
diff --git a/setup.cfg b/setup.cfg
index 4d1c31a..5e47f6e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,3 +2,7 @@
 max-line-length = 120
 ignore = E265, E126, E241
 
+[egg_info]
+tag_build = 
+tag_date = 0
+
diff --git a/test/test_asyncio.py b/test/test_asyncio.py
index 391b8f8..6fa4fd9 100644
--- a/test/test_asyncio.py
+++ b/test/test_asyncio.py
@@ -43,6 +43,7 @@ class Test_asyncio(unittest.TestCase):
         TEXT = b'Hello, World!\n'
         received = []
         actions = []
+        done = asyncio.Event()
 
         class Input(asyncio.Protocol):
 
@@ -74,7 +75,7 @@ class Test_asyncio(unittest.TestCase):
 
             def connection_lost(self, exc):
                 actions.append('close')
-                self._transport.loop.stop()
+                done.set()
 
             def pause_writing(self):
                 actions.append('pause')
@@ -90,7 +91,9 @@ class Test_asyncio(unittest.TestCase):
 
         client = serial_asyncio.create_serial_connection(self.loop, Output, PORT)
         self.loop.run_until_complete(client)
-        self.loop.run_forever()
+        self.loop.run_until_complete(done.wait())
+        pending = asyncio.all_tasks(self.loop)
+        self.loop.run_until_complete(asyncio.gather(*pending))
         self.assertEqual(b''.join(received), TEXT)
         self.assertEqual(actions, ['open', 'close'])
 

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in first set of .debs but not in second

lrwxrwxrwx  root/root   /usr/share/doc/python-serial-asyncio-doc/html/_static/sphinx_highlight.js -> ../../../../javascript/sphinxdoc/1.0/sphinx_highlight.js

Control files of package python-serial-asyncio-doc: lines which differ (wdiff format)

  • Depends: libjs-jquery, libjs-sphinxdoc (>= 5.2), 5.0), sphinx-rtd-theme-common (>= 1.2.0+dfsg) 1.2.0~rc1+dfsg)

No differences were encountered between the control files of package python3-serial-asyncio

More details

Full run details