Git Product home page Git Product logo

aiokatcp's People

Contributors

bmerry avatar dependabot[bot] avatar james-smith-za avatar ludwigschwardt avatar skajohanventer avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

richarms

aiokatcp's Issues

Improve support for integer-like types

The type registration system currently only uses __mro__, which means it doesn't work with ABCs like numbers.Integral. In Python 3, types like numpy.int64 don't inherit from int, so they currently crash if set as sensor values or otherwise used in katcp messages.

One approach is to change the type registration system to work with isinstance and to register ABCs instead of concrete classes. That needs some investigation because mypy doesn't work well with the numbers ABCs.

An alternative is to modify the sensor class to cast value updates to the sensor's registered type. That would fix the problem of setting a sensor to a numpy integer (but with the side effect that reading back the value gives you a different type of object from what you set), but wouldn't help for other messages.

"socket.send() raised exception." after client disconnect

When the server sends informs to a client that is disconnected, it causes a log message of

socket.send() raised exception

to be repeated each time. For example, run this server, connect a client and issue ?sensor-sampling ticks event, then kill the client.

#!/usr/bin/env python3
import asyncio
import logging

import aiokatcp


class Server(aiokatcp.DeviceServer):
    VERSION = 'test-1.0'
    BUILD_STATE = 'test-1.0.0'

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.sensor = aiokatcp.Sensor(int, 'ticks', 'stuff')
        self.sensors.add(self.sensor)


async def main():
    server = Server('localhost', 4444)
    await server.start()
    while True:
        await asyncio.sleep(0.1)
        server.sensor.value += 1

if __name__ == '__main__':
    logging.basicConfig()
    logging.warning('Startup!')
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()

It is most likely related to python/asyncio#301, although not caused by it (since that bug was fixed in 3.5.1). In particular, it may be necessary to change the API for out-of-band informs to use coroutines so that the queue can be drained.

ConnectionResetError leads to unwanted error

If a client connects and immediately disconnects, it can cause this exception trace, which should be handled a bit more gracefully:

Exception in connection handler [192.168.6.62:39646]
Traceback (most recent call last):

  File "/home/kat/ve3/lib/python3.5/site-packages/aiokatcp/connection.py", line 200, in _done_callback
    task.result()

  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception

  File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)

  File "/home/kat/ve3/lib/python3.5/site-packages/aiokatcp/connection.py", line 183, in _run
    msg = await read_message(self.reader)

  File "/home/kat/ve3/lib/python3.5/site-packages/aiokatcp/connection.py", line 94, in read_message
    raw = await stream.readuntil()

  File "/usr/lib/python3.5/asyncio/streams.py", line 574, in readuntil
    yield from self._wait_for_data('readuntil')

  File "/usr/lib/python3.5/asyncio/streams.py", line 457, in _wait_for_data
    yield from self._waiter

  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.

  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()

  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception

  File "/usr/lib/python3.5/asyncio/selector_events.py", line 662, in _read_ready
    data = self._sock.recv(self.max_size)

ConnectionResetError: [Errno 104] Connection reset by peer

Tests failing with Python 3.7

I've enabled Python 3.7 in Travis and can't currently make the tests pass. There is some difference in how issubclass behaves that is breaking the type registration system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.