Wykres commitów

5 Commity (c2b82817c7439ae7b04009678ad05ce136709404)

Autor SHA1 Wiadomość Data
Konstantin Gründger c2b82817c7 Fix for fortyfour #44 2017-12-13 19:26:56 +01:00
Anze Kolar 13cc75cf03 Allow client to do sequential connect-disconnect
With introduction of the kill switch it was impossible to restart the
consumption of the OGN messages after a .disconnect() method has been
called.

This commit resets the kill flag after .connect() has been called.

Minimal example:

```
client = AprsClient(aprs_user='testuser', aprs_filter='')
client.connect()
client.run(callback=lambda x: x, autoreconnect=True)
...
client.disconnect()
client.connect()
client.run()
```
2017-07-20 15:28:01 +02:00
Anze Kolar 182f9518a4 Add kill flag to AprsClient
When starting an AprsClient with AprsClient.run(...) the client enters
a loop without an exit condition (i.e. a while True loop).  If autoreconnect
is set to True, it is impossible to exit the aforementioned loop even if
AprsClient.disconnect() is called.

This causes problems when running the client in a thread (or as a
background service, etc.) as the process will not join nor terminate
unless explicitly shutdown with SIGKILL.

Minimal example:

```
import signal

from ogn.client import AprsClient
from ogn.parser import parse_aprs, parse_ogn_beacon, ParseError

def process_beacon(raw_message):
    print('Received message')

client = AprsClient(aprs_user='N0CALL')
signal.signal(signal.SIGTERM, lambda signo, stackno: client.disconnect())
client.connect()
client.run(callback=process_beacon, autoreconnect=True)
```

This commit fixes such issues by adding a kill flag that is raised when
calling AprsClien.disconnect() to the while conditions of both loops inside
AprsClient.run().

Note: the outermost loop could still remain a while True loop as the
exit condition is checked at the end of the loop body.
2017-07-20 11:12:04 +02:00
Fabian P. Schmidt fd53e6a3df client: Add timed callback
A timed callback allows the modification of server-side filters
during runtime (the client instance provided as callback argument
includes the socket and its send function).

Since sock_file.readline() is blocking, a secure scheduling can't
be guaranteed but is likely due to regular server-sent status messages.
2016-03-25 19:11:14 +01:00
Fabian P. Schmidt abae52b165 Rename module ogn.gateway to ogn.client
Renamed also class ognGateway to AprsClient to comply with the PEP8 naming
convention and to emphasis that it is a generic aprs client, not ogn specific.
2016-03-08 02:05:50 +01:00