Skip to content

Commit 1ecfb49

Browse files
committed
Document context managers
1 parent c9ac376 commit 1ecfb49

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ Available methods in both classes are (see docstrings for more info):
3636
* send_command - Sends a single command to the RCON server.
3737
* send_commands - Sends multiple commands to the RCON server.
3838

39+
Note that both the sync/async clients can be used as sync/async context managers respectively.
40+
3941
The methods for sending/receiving packets are available in case you want to
4042
write your own packet handlers, but in most cases you will never need to touch
4143
these and can use send_command(s).
4244

4345
## Mentions
4446

45-
Thanks to [Truman Kilen](https://github.com/trumank) for the initial code / idea.
47+
Thanks to:
48+
- [Truman Kilen](https://github.com/trumank) for the initial code / idea.
49+
- [De Sa Léo](https://github.com/desaleo) for contributing context manager support.
4650

4751
## License
4852

factorio_rcon/_factorio_rcon.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class RCONClient(RCONSharedBase):
189189
Extra information:
190190
**All methods are not thread safe**
191191
Use AsyncRCONClient for coroutine based concurrency.
192+
This is usable as a context manager.
192193
If any exception is raised (all inherit from RCONBaseError) during operation,
193194
it is required that you reconnect to the RCON server (with .connect()).
194195
The server will not respond to any RCON requests if it is saving, so you should
@@ -434,6 +435,7 @@ class AsyncRCONClient(RCONSharedBase):
434435
435436
anyio allows you to use either asyncio or trio.
436437
All functions in this class are async.
438+
This is usable as an async context manager.
437439
If you want to set timeouts, use the cancellation system your existing framework
438440
provides or use anyio.move_on_after/fail_after.
439441
See https://anyio.readthedocs.io/en/latest/cancellation.html#timeouts.

0 commit comments

Comments
 (0)