https://github.com/marcinbor85/asyncapp
Simple object-oriented asynchronous application wrapper.
https://github.com/marcinbor85/asyncapp
async asynchronous asyncio framework serial serialport server skeleton template wrapper
Last synced: 3 months ago
JSON representation
Simple object-oriented asynchronous application wrapper.
- Host: GitHub
- URL: https://github.com/marcinbor85/asyncapp
- Owner: marcinbor85
- License: mit
- Created: 2018-01-14T18:26:30.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-15T08:06:12.000Z (about 8 years ago)
- Last Synced: 2025-12-22T11:38:57.022Z (3 months ago)
- Topics: async, asynchronous, asyncio, framework, serial, serialport, server, skeleton, template, wrapper
- Language: Python
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# asyncapp
Simple object-oriented asynchronous application wrapper.
## Main features
- Based on standard "asyncio" library
- Python3 compatible
- Simplified and robust stopping of coroutines
- No warnings during application stopping (a common newbies issue)
- Some simplified IO async tools like tcp server and serial port
## Library instalation
```
sudo pip install asyncapp
```
## Usage:
```python
from asyncapp import AsyncApp
import asyncio
class TestAsyncApp(AsyncApp):
def on_start(self, loop):
asyncio.ensure_future(self.my_loop('fast', 4, 0.3))
asyncio.ensure_future(self.my_loop('slow', 2, 1.0))
print('started')
def on_stop(self, loop):
print('stopped')
async def my_loop(self, name, iters, delay):
while self.is_run():
await asyncio.sleep(delay)
print(name, iters)
iters -= 1
if iters == 0:
self.stop()
if __name__ == '__main__':
app = TestAsyncApp()
app.start()
```