-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathChangelog
1882 lines (1230 loc) · 48.2 KB
/
Changelog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.. _changelog:
================
Change history
================
.. version-4.4.0:
4.4.0
=====
:release-date: 2020-09-28 11:00 A.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Supervisors now raises :exc:`SystemExit` on max restarts exceeded.
- Queue: Now includes high pressure and pressure drop conditions.
This means you can now add callbacks when the queue is under high
pressure, and for when the pressure drops again.
- Service: Added ``human_tracebacks()`` method.
.. _version-4.3.2:
4.3.2
=====
:release-date: 2020-02-13 3:21 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Tracebacks: Added support for async generators.
Also added new functions:
+ :func:`~mode.utils.tracebacks.format_agen_stack`
+ :func:`~mode.utils.tracebacks.print_agen_stack`
- Logging: New version of log argument formatters.
The existing log argument formatter callbacks did
not have access to the original log record, so could
not make decisions based on matching the log message string
for example.
A new :func:`~mode.utils.logging.formatter2` decorator
has been added that registers callbacks taking two arguments.
Example:
.. sourcecode:: python
from mode.utils.logging import formatter2
@formatter2
def format_log_argument(arg: Any, record: logging.LogRecord):
# improve aiokafka logging to sort the list
# of topics logged when subscribing to topics
# and make it more human readable
if record.msg.startswith('Subscribing to topics'):
if isinstance(arg, frozenset):
return ', '.join(sorted(arg))
.. _version-4.3.1:
4.3.1
=====
:release-date: 2020-02-10 2:40 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Added :func:`mode.utils.times.humanize_seconds_ago`
This formats seconds float to text "n seconds ago",
or "just now" if less than one second.
- Added :func:`mode.utils.text.enumeration`
This formats a list of strings to a enumerated list,
for example:
.. sourcecode:: pycon
>>> text.enumeration(['x', 'y', '...'])
"1) x\n2) y\n3) ..."
.. _version-4.3.0:
4.3.0
=====
:release-date: 2020-01-22 2:25 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Threads: Now runs with :envvar:`PYTHONASYNCIODEBUG`.
- Threads: Fixed race condition where pending methods are lost
- utils.tracebacks: Adds ``print_coro_stack`` and
``format_coro_stack`` for debugging coroutines.
- Timers: Adds sleeptime and runtime to logs for more info.
- Threads: Threads now do two-way keepalive (thread -> parent, parent -> thread)
- Service: ``add_future`` now sets task name
- Worker: ``SIGUSR2`` now starts :mod:`pdb` session.
.. _version-4.2.0:
4.2.0
=====
:release-date: 2020-01-15 5:00 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Timers: Exclude timer callback time in drift calculation
- Service: `maybe_start()` now returns bool, and :const:`True`
if the service was started.
.. _version-4.1.9:
4.1.9
=====
:release-date: 2020-01-13 11:18 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- QueueServiceThread: Stop method queue before stopping child services.
- Small fixes to render graph images correctly.
.. _version-4.1.8:
4.1.8
=====
:release-date: 2020-01-07 4:00 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- ``ServiceThread.crash()`` now immediately sets exception
when called in main thread.
.. _version-4.1.7:
4.1.7
=====
:release-date: 2020-01-07 3:20 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Now depends on :pypi:`typing_extensions` (Issue #53)
This dependency was previously missing resulting in errors.
- Fixed :class:`~mode.threads.ServiceThread` hang on exceptions raised
(Issue #54).
Contributed by Alexey Basov (:github_user:`r313pp`)
and Jonathan Booth (:github_user:`jbooth-mastery`).
.. _version-4.1.6:
4.1.6
=====
:release-date: 2019-12-12 2:30 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- logging: Fixes recursion error on Python 3.6 (Issue #52)
- Makefile: Added `make develop` to install dependencies into the currently
activated virtualenv.
- Tests: Removed `was never awaited` warning during test run.
- CI: Revert back to using Python 3.7.5 for Windows build.
.. _version-4.1.5:
4.1.5
=====
:release-date: 2019-12-11 3:45 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Tests passing on Python 3.8.0
- Fixed typing related issues.
- Added :file:`__init__.py` to `mode.utils` package.
.. _version-4.1.4:
4.1.4
=====
:release-date: 2019-10-30 3:23 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Timers: Do not log drift for subsecond interval timers.
.. _version-4.1.3:
4.1.3
=====
:release-date: 2019-10-29 2:14 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Service: Ignore :exc:`asyncio.CancelledError` when a child service
is stopped.
- flight recorder: Adds ability to add logging extra-data that
propagates to child recorders.
.. _version-4.1.2:
4.1.2
=====
:release-date: 2019-10-02 3:41 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Adds easy flight recorder interface.
Instead of passing flight recorders around, we now have the concept
of a ``current_flight_recorder``.
There is also a new ``on_timeout`` wrapper object that always
logs to the current flight recorder:
.. sourcecode:: python
from mode.utils.logging import flight_recorder, on_timeout
async def main():
with flight_recorder(logger, timeout=300):
some_function()
def some_function():
on_timeout.error('Fetching data')
fetch_data()
on_timeout.error('Processing data')
process_data()
This uses a :class:`~mode.utils.locals.LocalStack`,
so flight recorders can be arbitrarily nested.
Once a flight recorder context exits, the previously active flight
recorder will be set active again.
- Logging: Default logging format now includes process PID.
- Adds :class:`~mode.utils.collections.Heap` as generic interface
to the heapq module
.. _version-4.1.1:
4.1.1
=====
:release-date: 2019-10-02 3:41 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- ``is_optional``: Now works with union having multiple args on Python 3.6.
- ``Proxy``: Due to `Python issue #29581`_ the ``source`` class option
to :class:`~mode.locals.Proxy` cannot be used on Python 3.6.
To work around this when support for 3.6 is a requirement
you can now use a ``__proxy_source__`` class attribute instead:
.. sourcecode:: python
class MappingProxy(Proxy[Mapping]):
proxy_source__ = Mapping
you want to support 3.7 and up you can continue to use the class syntax:
.. sourcecode:: python
class MappingProxy(Proxy[Mapping], source=Mapping):
...
.. _`Python issue #29581`: https://bugs.python.org/issue29581
.. _version-4.1.0:
4.1.0
=====
:release-date: 2019-09-27 2:00 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Worker: Adds ``override_logging`` option to use your own logging
setup (Issue #46).
- Service: Adds ``Service.crash_reason`` (Issue #50).
- Service: Adds ``remove_dependency`` to disable dependencies at runtime
(Issue #49).
Contributed by Martin Maillard.
- Timers: Increase max drift to silence noisy logs.
- Proxy: Adds support for lazy proxying of objects.
See :mod:`mode.locals`.
- Documentation improvements by:
+ :github_user:`tojkamaster`.
+ :github_user:`casio`
.. _version-4.0.1:
4.0.1
=====
:release-date: 2019-07-17 3:42 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Utils: :class:`~mode.utils.future.stampede` objects can now be
read by :pypi:`Sphinx` and :func:`inspect.signature`.
- CI: Adds CPython 3.7.3 to build matrix, and set as default for lint stages
.. _version-4.0.0:
4.0.0
=====
:release-date: 2019-05-07 2:21 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- 100% Test Coverage
- Fixed several edge case bugs that were never reported.
.. _version-3.2.2:
3.2.2
=====
:release-date: 2019-04-07 6:18 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- :class:`~mode.utils.typing.AsyncGenerator` takes two arguments.
Mistakenly had it take three arguments, like :class:`typing.Generator`.S
.. _version-3.2.1:
3.2.1
=====
:release-date: 2019-04-07 4:07 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Adds :class:`mode.utils.typing.AsyncGenerator`
to import :class:`typing.AsyncGenerator` missing from Python 3.6.0.
.. _version-3.2.0:
3.2.0
=====
:release-date: 2019-04-06 11:00 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Adds ``Service.itertimer``: used to perform periodic
tasks, but with automatic drift adjustment.
- Adds :func:`mode.utils.mocks.ContextMock`
To mock a regular context manager.
.. _version-3.1.3:
3.1.3
=====
:release-date: 2019-04-04 08:41 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- ``mode.utils.worker.exiting`` now takes option to print exceptions.
- Threads: Method queue "starting..." logs now logged with debug severity.
- Worker: execute_from_commandline no longer swallow errors if loop closed.
- Adds :class:`mode.locals.LocalStack`.
.. _version-3.1.2:
3.1.2
=====
:release-date: 2019-04-04 08:37 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
+ **Revoked release**: Version without changelog entry was uploaded to PyPI.
Please upgrade to 3.1.3.
.. _version-3.1.1:
3.1.1
=====
:release-date: 2019-03-27 10:02 A.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Service: property ``should_stop`` is now true if service crashed.
- Timers: Avoid drift + introduce a tiny bit of drift to timers.
Thanks to Bob Haddleton (:github_user:`bobh66`) for discovering
this issue.
.. _version-3.1.0:
3.1.0
=====
:release-date: 2019-03-21 03:26 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Adds :class:`~mode.utils.contexts.nullcontext`
and :class:`~mode.utils.contexts.asyncnullcontext`.
Backported from Python 3.7 you can import these
from :mod:`mode.utils.contexts`.
- Mode project changes:
+ Added :pypi:`bandit` to CI lint build.
+ Added :pypi:`pydocstyle` to CI lint build.
.. _version-3.0.13:
3.0.13
======
:release-date: 2019-03-20 04:58 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Adds ``CompositeLogger.warning`` alias to ``warn``.
:pypi:`flake8-logging-format` has a rule that says
you are only allowed to use ``.warning``, so going with that.
.. _version-3.0.12:
3.0.12
======
:release-date: 2019-03-20 03:23 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Adds :func:`~mode.utils.futures.all_tasks` as a backward compatible
:func:`asyncio.all_tasks`.
- Signal: Fixes ``.connect()`` decorator to work with parens and without
Signal decorator now works with parens:
.. sourcecode:: python
@signal.connect()
def my_handler(sender, **kwargs):
...
and without parens:
.. sourcecode:: python
@signal.connect
def my_handler(sender, **kwargs):
...
- Signal: Do not use weakref by default.
Using weakref by default meant it was too easy to connect
a signal handler to only have it disappear because there were
no more references to the object.
.. _version-3.0.11:
3.0.11
======
:release-date: 2019-03-19 08:50 A.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Adds ThrowableQueue._throw() for non-async version of .throw().
.. _version-3.0.10:
3.0.10
======
:release-date: 2019-03-14 03:55 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Worker: was giving successful exit code when an exception is raised.
The ``.execute_from_commandline`` method now always exits
(its return type is :class:`typing.NoReturn`).
- Adds :class:`~mode.utils.compat.NoReturn` to :mod:`mode.utils.compat`.
Import :class:`typing.NoReturn` from here to support Python versions
before 3.6.3.
.. _version-3.0.9:
3.0.9
=====
:release-date: 2019-03-08 01:20 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Threads: Add multiple workers for thread method queue.
Default number of workers is now 2, to allow for
two recursive calls.
- Signal: Use `Signal.label` instead of ``.indent`` to be more consistent.
- Signal: Properly set ``.name`` when signal is member of class.
- Adds ability to log the FULL traceback of :class:`asyncio.Task`.
- Service: Stop faster if stopped immediately after start
- Service: Correctly track dependencies for services added
using ``Service.on_init_dependencies`` (Issue #40).
Contributed by Nimi Wariboko Jr (:github_user:`nemosupremo`).
.. _version-3.0.8:
3.0.8
=====
:release-date: 2019-01-25 03:54 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Fixes ``DeprecationWarning`` importing from ``collections``.
- stampede: Fixed edge case where stampede wrapped function
called multiple times.
Calling the same stampede wrapped function multiple times
within the same event loop iteration would previously call
the function multiple times.
For example using :func:`asyncio.gather`:
.. sourcecode:: python
from mode.utils.futures import stampede
count = 0
@stampede
async def update_count():
global count
count += 1
async def main():
await asyncio.gather(
update_count(),
update_count(),
update_count(),
update_count(),
)
assert count == 1
Previously this would call the function four times, but with the
fix it's only called once and provides the expected result.
- Mocks: Adds :func:`~mode.utils.mocks.mask_module` and
:func:`~mode.utils.mocks.patch_module`.
- CI: Added Windows build.
- CI: Enabled random order for tests.
.. _version-3.0.7:
3.0.7
=====
:release-date: 2019-01-18 01:12 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- **ServiceThread** ``.stop()`` would wait for thread shutdown
even if thread was never started.
- **CI**: Adds CPython 3.7.2 and 3.6.8 to build matrix
.. _version-3.0.6:
3.0.6
=====
:release-date: 2019-01-07 12:10 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Adds ``%(extra)s`` as log format option.
To add additional context to your logging statements use for example::
logger.error('Foo', extra={'data': {'database': 'db1'}})
.. _version-3.0.5:
3.0.5
=====
:release-date: 2018-12-19 04:40 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Fixes compatibility with :pypi:`colorlog` 4.0.x.
Contributed by Ryan Whitten (:github_user:`rwhitten577`).
.. _version-3.0.4:
3.0.4
=====
:release-date: 2018-12-07 04:40 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Now depends on :pypi:`mypy_extensions`.
.. _version-3.0.3:
3.0.3
=====
:release-date: 2018-12-07 3:22 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Threads: Fixed delay in shutdown if ``on_thread_stop`` callback raises
exception.
- Service: Stopping of children no longer propagates exceptions, to ensure
other services are still stopped.
- Worker: Fixed race condition if worker stopped before being fully started.
This would lead the worker to shutdown early before fully stopping
all dependent services.
- Tests: Adds :class:`~mode.utils.mocks.AsyncMagicMock`
.. _version-3.0.2:
3.0.2
=====
:release-date: 2018-12-07 1:14 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Worker: Fixes crash on Windows where signal handlers cannot be registered.
- Utils: Adds :func:`~mode.utils.objects.shortname` to get non-qualified
object path.
- Utils: Adds :func:`~mode.utils.objects.canonshortname` to get non-qualified
object path that attempts to resolve the real name of ``__main__``.
.. _version-3.0.1:
3.0.1
=====
:release-date: 2018-12-06 10:20 A.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Worker: Added new callback ``on_worker_shutdown``.
- Worker: Do not stop twice, instead wait for original stop to complete.
Signals would start multiple stopping coroutines, leading to
the worker shutting down too fast.
- Threads: All ``ServiceThread`` services needs a keepalive
coroutine to be scheduled.
- Supervisor: Fixed issue with ``CrashingSupervisor`` where
service would not crash.
.. _version-3.0.0:
3.0.0
=====
:release-date: 2018-11-30 4:48 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- ``ServiceThread`` no longer uses ``run_in_executor``.
Since services are long running, it is not a good idea for
them to block pool worker threads. Instead we run one
thread for every ServiceThread.
- Adds :class:`~mode.threads.QueuedServiceThread`
This subclass of :class:`~mode.threads.ServiceThread` enables
the use of a queue to send work to the service thread.
This is useful for services that wrap blocking network clients
for example.
If you have a blocking Redis client you could run it in a separate
thread like this:
.. code-block:: python
class Redis(QueuedServiceThread):
_client: StrictRedis = None
async def on_start(self) -> None:
self._client = StrictRedis()
async def get(self, key):
return await self.call_thread(self._client.get, key)
async def set(self, key, value):
await self.call_thread(self._client.set, key, value)
The actual redis client will be running in a separate thread (with a
separate event loop). The ``get`` and ``set`` methods will delegate
to the thread, and return only when the thread is finished handling
them and is ready with a result:
.. sourcecode:: python
async def use_redis():
# We use async-with-statement here, but
# can also do `await redis.start()` then `await redis.stop()`
async with Redis() as redis:
await redis.set(key='foo', value='bar')
assert await redis.get(key='foo') == 'bar'
- Collections: ``FastUserSet`` and ``ManagedUserSet`` now implements
all :class:`set` operations.
- Collections are now generic types.
You can now subclass collections with typing information:
- ``class X(FastUserDict[str, int]): ...``
- ``class X(ManagedUserDict[str, int]): ...``
- ``class X(FastUserSet[str]): ...``
- ``class X(ManagedUserSet[str]): ...``
- :func:`~mode.utils.futures.maybe_async` utility now
also works with ``@asyncio.coroutine`` decorated coroutines.
- Worker: SIGUSR1 cry handler: Fixed crash when coroutine does not have
``__name__`` attribute.
.. _version-2.0.4:
2.0.4
=====
:release-date: 2018-11-19 1:07 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- ``FlowControlQueue.clear`` now cancels all waiting for ``Queue.put``.
.. _version-2.0.3:
2.0.3
=====
:release-date: 2018-11-05 5:20 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Adds `Service.wait_first(*coros)`
Wait for the first coroutine to return, where coroutines can also
be :class:`asyncio.Event`.
Returns :class:`mode.services.WaitResults` with fields:
- ``.done`` - List of arguments that are now done.
- ``.results`` - List of return values in order of ``.done``.
- ``.stopped`` - Set to True if the service was stopped.
.. _version-2.0.2:
2.0.2
=====
:release-date: 2018-11-03 9:07 A.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Now depends on :pypi:`aiocontextvars` 0.2
This release uses :pep:`508` syntax for conditional requirements,
as :ref:`version-2.0.1` did not work when installing wheel.
.. _version-2.0.1:
2.0.1
=====
:release-date: 2018-11-02 7:38 P.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Now depends on :pypi:`aiocontextvars` 0.2
.. _version-2.0.0:
2.0.0
=====
:release-date: 2018-11-02 9:12 A.M PST
:release-by: Ask Solem (:github_user:`ask`)
- Services now create the event loop on demand.
This means the event loop is no longer created in `Service.__init__`
so that services can be defined at module scope without initializing
the loop.
This makes the ``ServiceProxy`` pattern redundant for most use cases.
- Adds ``.utils.compat.current_task`` as alias for
:mod:`asyncio.current_task`.
- Adds support for contextvars in Python 3.6 using :pypi:`aiocontextvars`.
In mode services you can now use :mod:`contextvars` module even
on Python 3.6, thanks to the work of :github_user:`fantix`.
.. _version-1.18.2:
1.18.2
======
:release-date: 2018-11-30 6:23 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Worker: SIGUSR1 cry handler: Fixed crash when coroutine does not have
``__name__`` attribute.
.. _version-1.18.1:
1.18.1
======
:release-date: 2018-10-03 2:49 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- **Service**: ``Service.from_awaitable(coro)`` improvements.
The resulting ``service.start`` will now:
+ Convert awaitable to :class:`asyncio.Task`.
+ Wait for task to complete.
then ``service.stop`` will:
+ Cancel the task.
This ensures an ``asyncio.sleep(10.0)`` within can be
cancelled. If you need some operation to absolutely finish you must
use `asyncio.shield`.
- **Utils**: ``cached_property`` adds new ``.is_set(o)`` method on descriptor
This can be used to test for the attribute having been cached/used.
If you have a class with a ``cached_property``:
.. sourcecode:: python
from mode.utils.objects import cached_property
class X:
@cached_property
def foo(self):
return 42
x = X()
print(x.foo)
From an instance you can now check if the property was accessed:
.. sourcecode:: python
if type(x).foo.is_set(x):
print(f'Someone accessed x.foo and it was cached as: {x.foo}')
.. _version-1.18.0:
1.18.0
======
:release-date: 2018-10-02 3:32 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- **Worker**: Fixed error when starting :pypi:`aioconsole` on ``--debug``
The worker would crash with:
.. sourcecode:: text
TypeError: Use `self.add_context(ctx)` for non-async context
when started with the ``--debug`` flag.
- **Worker**: New ``daemon`` argument controls shutdown of worker.
When the flag is enabled, the default, the worker will not shut
down until the worker instance is either explicitly stopped, or
it receives a terminating process signal (``SIGINT``/``SIGTERM``/etc.)
When disabled, the worker for the given service will shut down as soon as
``await service.start()`` returns.
You can think of it as a flag for daemons, but one that doesn't actually
do any of the UNIX daemonization stuff (detaching, etc.). It merely
means the worker continues to run in the background until stopped by
signal.
- **Service**: Added class method: ``Service.from_awaitable``.
This can be used to create a service out of any coroutine
or :class:`~typing.Awaitable`:
.. sourcecode:: python
from mode import Service, Worker
async def me(interval=1.0):
print('ME STARTING')
await asyncio.sleep(interval)
print('ME STOPPING')
def run_worker(interval=1.0):
coro = me(interval=1.0)
Worker(Service.from_awaitable(coro)).execute_from_commandline()
if __name__ == '__main__':
run_worker()
.. note::
Using a service with ``await self.sleep(1.0)`` is often not what
you want, as stopping the service will have to wait for the sleep
to finish.
``Service.from_awaitable`` is as such a last resort for cases
where you're provided a coroutine you cannot implement as a service.
``Service.sleep()`` is useful as it will stop sleeping immediately
if the service is stopped:
class Me(Service):
async def on_start(self) -> None:
await self.sleep(1.0)
- **Service**: New method ``_repr_name`` can be used to override the service
class name used in ``repr(service)``.
.. _version-1.17.3:
1.17.3
======
:release-date: 2018-09-18 4:00 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Service: New attribute ``mundane_level`` decides the logging level
of mundane logging events such as "[X] Starting...", for starting/stopping
and tasks being cancelled.
The value for this must be a logger level name, and is ``"info"`` by
default.
If logging for a service is noisy at info-level, you can move it
to debug level by setting this attribute to ``"debug"``:
.. sourcecode:: python
class X(Service):
mundane_level = 'debug'
.. _version-1.17.2:
1.17.2
======
:release-date: 2018-09-17 3:00 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Removed and fixed import from ``collections`` that will be moved
to ``collections.abc`` in Python 3.8.
This also silences a ``DeprecationWarning`` that was being emitted
on Python 3.7.
- Type annotations now passing checks on :pypi:`mypy` 0.630.
.. _version-1.17.1:
1.17.1
======
:release-date: 2018-09-13 6:27 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- Fixes several bugs related to unwrapping ``Optional[List[..]]``
in :func:`mode.utils.objects.annotations`.
This functionality is not really related to mode at all, so
should be moved out of this library. Faust uses it for models.
.. _version-1.17.0:
1.17.0
======
:release-date: 2018-09-12 5:39 P.M PDT
:release-by: Ask Solem (:github_user:`ask`)
- New async iterator utility: :class:`~mode.utils.aiter.arange`