|
525 | 525 | same process.
|
526 | 526 | (Contributed by Victor Stinner in :gh:`120057`.)
|
527 | 527 |
|
| 528 | +* Add the :data:`~os.SCHED_DEADLINE` and :data:`~os.SCHED_NORMAL` constants |
| 529 | + to the :mod:`os` module. |
| 530 | + (Contributed by James Roy in :gh:`127688`.) |
| 531 | + |
528 | 532 |
|
529 | 533 | pathlib
|
530 | 534 | -------
|
|
599 | 603 | which only exists in specialized builds of Python, may now return objects
|
600 | 604 | from other interpreters than the one it's called in.
|
601 | 605 |
|
| 606 | +sys.monitoring |
| 607 | +-------------- |
| 608 | + |
| 609 | +Two new events are added: :monitoring-event:`BRANCH_LEFT` and |
| 610 | +:monitoring-event:`BRANCH_RIGHT`. The ``BRANCH`` event is deprecated. |
602 | 611 |
|
603 | 612 | tkinter
|
604 | 613 | -------
|
@@ -780,6 +789,96 @@ asyncio
|
780 | 789 | It now raises a :exc:`RuntimeError` if there is no current event loop.
|
781 | 790 | (Contributed by Kumar Aditya in :gh:`126353`.)
|
782 | 791 |
|
| 792 | + There's a few patterns that use :func:`asyncio.get_event_loop`, most |
| 793 | + of them can be replaced with :func:`asyncio.run`. |
| 794 | + |
| 795 | + If you're running an async function, simply use :func:`asyncio.run`. |
| 796 | + |
| 797 | + Before:: |
| 798 | + |
| 799 | + async def main(): |
| 800 | + ... |
| 801 | + |
| 802 | + |
| 803 | + loop = asyncio.get_event_loop() |
| 804 | + try: |
| 805 | + loop.run_until_complete(main()) |
| 806 | + finally: |
| 807 | + loop.close() |
| 808 | + |
| 809 | + After:: |
| 810 | + |
| 811 | + async def main(): |
| 812 | + ... |
| 813 | + |
| 814 | + asyncio.run(main()) |
| 815 | + |
| 816 | + If you need to start something, e.g. a server listening on a socket |
| 817 | + and then run forever, use :func:`asyncio.run` and an |
| 818 | + :class:`asyncio.Event`. |
| 819 | + |
| 820 | + Before:: |
| 821 | + |
| 822 | + def start_server(loop): |
| 823 | + ... |
| 824 | + |
| 825 | + loop = asyncio.get_event_loop() |
| 826 | + try: |
| 827 | + start_server(loop) |
| 828 | + loop.run_forever() |
| 829 | + finally: |
| 830 | + loop.close() |
| 831 | + |
| 832 | + After:: |
| 833 | + |
| 834 | + def start_server(loop): |
| 835 | + ... |
| 836 | + |
| 837 | + async def main(): |
| 838 | + start_server(asyncio.get_running_loop()) |
| 839 | + await asyncio.Event().wait() |
| 840 | + |
| 841 | + asyncio.run(main()) |
| 842 | + |
| 843 | + If you need to run something in an event loop, then run some blocking |
| 844 | + code around it, use :class:`asyncio.Runner`. |
| 845 | + |
| 846 | + Before:: |
| 847 | + |
| 848 | + async def operation_one(): |
| 849 | + ... |
| 850 | + |
| 851 | + def blocking_code(): |
| 852 | + ... |
| 853 | + |
| 854 | + async def operation_two(): |
| 855 | + ... |
| 856 | + |
| 857 | + loop = asyncio.get_event_loop() |
| 858 | + try: |
| 859 | + loop.run_until_complete(operation_one()) |
| 860 | + blocking_code() |
| 861 | + loop.run_until_complete(operation_two()) |
| 862 | + finally: |
| 863 | + loop.close() |
| 864 | + |
| 865 | + After:: |
| 866 | + |
| 867 | + async def operation_one(): |
| 868 | + ... |
| 869 | + |
| 870 | + def blocking_code(): |
| 871 | + ... |
| 872 | + |
| 873 | + async def operation_two(): |
| 874 | + ... |
| 875 | + |
| 876 | + with asyncio.Runner() as runner: |
| 877 | + runner.run(operation_one()) |
| 878 | + blocking_code() |
| 879 | + runner.run(operation_two()) |
| 880 | + |
| 881 | + |
783 | 882 |
|
784 | 883 | collections.abc
|
785 | 884 | ---------------
|
@@ -1050,6 +1149,11 @@ New features
|
1050 | 1149 | a :exc:`UnicodeError` object.
|
1051 | 1150 | (Contributed by Bénédikt Tran in :gh:`127691`.)
|
1052 | 1151 |
|
| 1152 | +* Add :c:func:`PyMonitoring_FireBranchLeftEvent` and |
| 1153 | + :c:func:`PyMonitoring_FireBranchRightEvent` for generating |
| 1154 | + :monitoring-event:`BRANCH_LEFT` and :monitoring-event:`BRANCH_RIGHT` |
| 1155 | + events, respectively. |
| 1156 | + |
1053 | 1157 |
|
1054 | 1158 | Porting to Python 3.14
|
1055 | 1159 | ----------------------
|
@@ -1083,6 +1187,10 @@ Deprecated
|
1083 | 1187 |
|
1084 | 1188 | .. include:: ../deprecations/c-api-pending-removal-in-future.rst
|
1085 | 1189 |
|
| 1190 | +* The ``PyMonitoring_FireBranchEvent`` function is deprecated and should |
| 1191 | + be replaced with calls to :c:func:`PyMonitoring_FireBranchLeftEvent` |
| 1192 | + and :c:func:`PyMonitoring_FireBranchRightEvent`. |
| 1193 | + |
1086 | 1194 | Removed
|
1087 | 1195 | -------
|
1088 | 1196 |
|
|
0 commit comments