7
7
msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
- "POT-Creation-Date : 2024-05-09 00:03+0000\n "
10
+ "POT-Creation-Date : 2024-05-23 00:03+0000\n "
11
11
"PO-Revision-Date : 2018-05-23 16:12+0000\n "
12
12
"Last-Translator : Adrian Liaw <adrianliaw2000@gmail.com>\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -696,7 +696,7 @@ msgid ""
696
696
"by the platform."
697
697
msgstr ""
698
698
699
- #: ../../library/threading.rst:541 ../../library/threading.rst:621
699
+ #: ../../library/threading.rst:541 ../../library/threading.rst:632
700
700
msgid "Acquire a lock, blocking or non-blocking."
701
701
msgstr ""
702
702
@@ -728,8 +728,8 @@ msgid ""
728
728
"if not (for example if the *timeout* expired)."
729
729
msgstr ""
730
730
731
- #: ../../library/threading.rst:559 ../../library/threading.rst:643
732
- #: ../../library/threading.rst:890
731
+ #: ../../library/threading.rst:559 ../../library/threading.rst:670
732
+ #: ../../library/threading.rst:917
733
733
msgid "The *timeout* parameter is new."
734
734
msgstr ""
735
735
@@ -756,7 +756,7 @@ msgstr ""
756
756
msgid "When invoked on an unlocked lock, a :exc:`RuntimeError` is raised."
757
757
msgstr ""
758
758
759
- #: ../../library/threading.rst:578 ../../library/threading.rst:659
759
+ #: ../../library/threading.rst:578 ../../library/threading.rst:686
760
760
msgid "There is no return value."
761
761
msgstr ""
762
762
@@ -779,70 +779,112 @@ msgstr ""
779
779
780
780
#: ../../library/threading.rst:597
781
781
msgid ""
782
- "To lock the lock, a thread calls its :meth:`~RLock.acquire` method; this "
783
- "returns once the thread owns the lock. To unlock the lock, a thread calls "
784
- "its :meth:`~Lock.release` method. :meth:`~Lock.acquire`/:meth:`~Lock."
785
- "release` call pairs may be nested; only the final :meth:`~Lock.release` "
786
- "(the :meth:`~Lock.release` of the outermost pair) resets the lock to "
787
- "unlocked and allows another thread blocked in :meth:`~Lock.acquire` to "
788
- "proceed."
782
+ "Threads call a lock's :meth:`~RLock.acquire` method to lock it, and its :"
783
+ "meth:`~Lock.release` method to unlock it."
789
784
msgstr ""
790
785
791
- #: ../../library/threading.rst:604
786
+ #: ../../library/threading.rst:602
792
787
msgid ""
793
- "Reentrant locks also support the :ref:`context management protocol <with-"
794
- "locks>`."
788
+ "Reentrant locks support the :ref:`context management protocol <with-locks>`, "
789
+ "so it is recommended to use :keyword:`with` instead of manually calling :"
790
+ "meth:`~RLock.acquire` and :meth:`~RLock.release` to handle acquiring and "
791
+ "releasing the lock for a block of code."
795
792
msgstr ""
796
793
797
- #: ../../library/threading.rst:609
794
+ #: ../../library/threading.rst:607
795
+ msgid ""
796
+ "RLock's :meth:`~RLock.acquire`/:meth:`~RLock.release` call pairs may be "
797
+ "nested, unlike Lock's :meth:`~Lock.acquire`/:meth:`~Lock.release`. Only the "
798
+ "final :meth:`~RLock.release` (the :meth:`~Lock.release` of the outermost "
799
+ "pair) resets the lock to an unlocked state and allows another thread blocked "
800
+ "in :meth:`~RLock.acquire` to proceed."
801
+ msgstr ""
802
+
803
+ #: ../../library/threading.rst:613
804
+ msgid ""
805
+ ":meth:`~RLock.acquire`/:meth:`~RLock.release` must be used in pairs: each "
806
+ "acquire must have a release in the thread that has acquired the lock. "
807
+ "Failing to call release as many times the lock has been acquired can lead to "
808
+ "deadlock."
809
+ msgstr ""
810
+
811
+ #: ../../library/threading.rst:620
798
812
msgid ""
799
813
"This class implements reentrant lock objects. A reentrant lock must be "
800
814
"released by the thread that acquired it. Once a thread has acquired a "
801
815
"reentrant lock, the same thread may acquire it again without blocking; the "
802
816
"thread must release it once for each time it has acquired it."
803
817
msgstr ""
804
818
805
- #: ../../library/threading.rst:614
819
+ #: ../../library/threading.rst:625
806
820
msgid ""
807
821
"Note that ``RLock`` is actually a factory function which returns an instance "
808
822
"of the most efficient version of the concrete RLock class that is supported "
809
823
"by the platform."
810
824
msgstr ""
811
825
812
- #: ../../library/threading.rst:623
826
+ #: ../../library/threading.rst:636
827
+ msgid ":ref:`Using RLock as a context manager <with-locks>`"
828
+ msgstr ""
829
+
830
+ #: ../../library/threading.rst:637
813
831
msgid ""
814
- "When invoked without arguments: if this thread already owns the lock, "
815
- "increment the recursion level by one, and return immediately. Otherwise, if "
816
- "another thread owns the lock, block until the lock is unlocked. Once the "
817
- "lock is unlocked (not owned by any thread), then grab ownership, set the "
818
- "recursion level to one, and return. If more than one thread is blocked "
819
- "waiting until the lock is unlocked, only one at a time will be able to grab "
820
- "ownership of the lock. There is no return value in this case."
832
+ "Recommended over manual :meth:`!acquire` and :meth:`release` calls whenever "
833
+ "practical."
821
834
msgstr ""
822
835
823
- #: ../../library/threading.rst:631
836
+ #: ../../library/threading.rst:641
824
837
msgid ""
825
- "When invoked with the *blocking* argument set to ``True``, do the same thing "
826
- "as when called without arguments, and return ``True``."
838
+ "When invoked with the *blocking* argument set to ``True`` (the default):"
839
+ msgstr ""
840
+
841
+ #: ../../library/threading.rst:643 ../../library/threading.rst:655
842
+ msgid "If no thread owns the lock, acquire the lock and return immediately."
827
843
msgstr ""
828
844
829
- #: ../../library/threading.rst:634
845
+ #: ../../library/threading.rst:645
830
846
msgid ""
831
- "When invoked with the *blocking* argument set to ``False``, do not block. "
832
- "If a call without an argument would block, return ``False`` immediately; "
833
- "otherwise, do the same thing as when called without arguments, and return "
834
- "``True``."
847
+ "If another thread owns the lock, block until we are able to acquire lock, or "
848
+ "*timeout*, if set to a positive float value."
835
849
msgstr ""
836
850
837
- #: ../../library/threading.rst:638
851
+ #: ../../library/threading.rst:648
838
852
msgid ""
839
- "When invoked with the floating-point *timeout* argument set to a positive "
840
- "value, block for at most the number of seconds specified by *timeout* and as "
841
- "long as the lock cannot be acquired. Return ``True`` if the lock has been "
842
- "acquired, ``False`` if the timeout has elapsed ."
853
+ "If the same thread owns the lock, acquire the lock again, and return "
854
+ "immediately. This is the difference between :class:`Lock` and :class:`! "
855
+ "RLock`; :class:`Lock` handles this case the same as the previous, blocking "
856
+ "until the lock can be acquired ."
843
857
msgstr ""
844
858
845
- #: ../../library/threading.rst:649
859
+ #: ../../library/threading.rst:653
860
+ msgid "When invoked with the *blocking* argument set to ``False``:"
861
+ msgstr ""
862
+
863
+ #: ../../library/threading.rst:657
864
+ msgid "If another thread owns the lock, return immediately."
865
+ msgstr ""
866
+
867
+ #: ../../library/threading.rst:659
868
+ msgid ""
869
+ "If the same thread owns the lock, acquire the lock again and return "
870
+ "immediately."
871
+ msgstr ""
872
+
873
+ #: ../../library/threading.rst:662
874
+ msgid ""
875
+ "In all cases, if the thread was able to acquire the lock, return ``True``. "
876
+ "If the thread was unable to acquire the lock (i.e. if not blocking or the "
877
+ "timeout was reached) return ``False``."
878
+ msgstr ""
879
+
880
+ #: ../../library/threading.rst:666
881
+ msgid ""
882
+ "If called multiple times, failing to call :meth:`~RLock.release` as many "
883
+ "times may lead to deadlock. Consider using :class:`!RLock` as a context "
884
+ "manager rather than calling acquire/release directly."
885
+ msgstr ""
886
+
887
+ #: ../../library/threading.rst:676
846
888
msgid ""
847
889
"Release a lock, decrementing the recursion level. If after the decrement it "
848
890
"is zero, reset the lock to unlocked (not owned by any thread), and if any "
@@ -851,25 +893,26 @@ msgid ""
851
893
"is still nonzero, the lock remains locked and owned by the calling thread."
852
894
msgstr ""
853
895
854
- #: ../../library/threading.rst:655
896
+ #: ../../library/threading.rst:682
855
897
msgid ""
856
898
"Only call this method when the calling thread owns the lock. A :exc:"
857
- "`RuntimeError` is raised if this method is called when the lock is unlocked."
899
+ "`RuntimeError` is raised if this method is called when the lock is not "
900
+ "acquired."
858
901
msgstr ""
859
902
860
- #: ../../library/threading.rst:665
903
+ #: ../../library/threading.rst:692
861
904
msgid "Condition Objects"
862
905
msgstr ""
863
906
864
- #: ../../library/threading.rst:667
907
+ #: ../../library/threading.rst:694
865
908
msgid ""
866
909
"A condition variable is always associated with some kind of lock; this can "
867
910
"be passed in or one will be created by default. Passing one in is useful "
868
911
"when several condition variables must share the same lock. The lock is part "
869
912
"of the condition object: you don't have to track it separately."
870
913
msgstr ""
871
914
872
- #: ../../library/threading.rst:672
915
+ #: ../../library/threading.rst:699
873
916
msgid ""
874
917
"A condition variable obeys the :ref:`context management protocol <with-"
875
918
"locks>`: using the ``with`` statement acquires the associated lock for the "
@@ -878,7 +921,7 @@ msgid ""
878
921
"associated lock."
879
922
msgstr ""
880
923
881
- #: ../../library/threading.rst:678
924
+ #: ../../library/threading.rst:705
882
925
msgid ""
883
926
"Other methods must be called with the associated lock held. The :meth:"
884
927
"`~Condition.wait` method releases the lock, and then blocks until another "
@@ -887,14 +930,14 @@ msgid ""
887
930
"and returns. It is also possible to specify a timeout."
888
931
msgstr ""
889
932
890
- #: ../../library/threading.rst:684
933
+ #: ../../library/threading.rst:711
891
934
msgid ""
892
935
"The :meth:`~Condition.notify` method wakes up one of the threads waiting for "
893
936
"the condition variable, if any are waiting. The :meth:`~Condition."
894
937
"notify_all` method wakes up all threads waiting for the condition variable."
895
938
msgstr ""
896
939
897
- #: ../../library/threading.rst:688
940
+ #: ../../library/threading.rst:715
898
941
msgid ""
899
942
"Note: the :meth:`~Condition.notify` and :meth:`~Condition.notify_all` "
900
943
"methods don't release the lock; this means that the thread or threads "
@@ -903,7 +946,7 @@ msgid ""
903
946
"or :meth:`~Condition.notify_all` finally relinquishes ownership of the lock."
904
947
msgstr ""
905
948
906
- #: ../../library/threading.rst:694
949
+ #: ../../library/threading.rst:721
907
950
msgid ""
908
951
"The typical programming style using condition variables uses the lock to "
909
952
"synchronize access to some shared state; threads that are interested in a "
@@ -915,7 +958,7 @@ msgid ""
915
958
"situation with unlimited buffer capacity::"
916
959
msgstr ""
917
960
918
- #: ../../library/threading.rst:714
961
+ #: ../../library/threading.rst:741
919
962
msgid ""
920
963
"The ``while`` loop checking for the application's condition is necessary "
921
964
"because :meth:`~Condition.wait` can return after an arbitrary long time, and "
@@ -925,7 +968,7 @@ msgid ""
925
968
"checking, and eases the computation of timeouts::"
926
969
msgstr ""
927
970
928
- #: ../../library/threading.rst:726
971
+ #: ../../library/threading.rst:753
929
972
msgid ""
930
973
"To choose between :meth:`~Condition.notify` and :meth:`~Condition."
931
974
"notify_all`, consider whether one state change can be interesting for only "
@@ -934,60 +977,60 @@ msgid ""
934
977
"thread."
935
978
msgstr ""
936
979
937
- #: ../../library/threading.rst:734
980
+ #: ../../library/threading.rst:761
938
981
msgid ""
939
982
"This class implements condition variable objects. A condition variable "
940
983
"allows one or more threads to wait until they are notified by another thread."
941
984
msgstr ""
942
985
943
- #: ../../library/threading.rst:737
986
+ #: ../../library/threading.rst:764
944
987
msgid ""
945
988
"If the *lock* argument is given and not ``None``, it must be a :class:`Lock` "
946
989
"or :class:`RLock` object, and it is used as the underlying lock. Otherwise, "
947
990
"a new :class:`RLock` object is created and used as the underlying lock."
948
991
msgstr ""
949
992
950
- #: ../../library/threading.rst:741 ../../library/threading.rst:865
951
- #: ../../library/threading.rst:911 ../../library/threading.rst:963
952
- #: ../../library/threading.rst:1031
993
+ #: ../../library/threading.rst:768 ../../library/threading.rst:892
994
+ #: ../../library/threading.rst:938 ../../library/threading.rst:990
995
+ #: ../../library/threading.rst:1058
953
996
msgid "changed from a factory function to a class."
954
997
msgstr ""
955
998
956
- #: ../../library/threading.rst:746
999
+ #: ../../library/threading.rst:773
957
1000
msgid ""
958
1001
"Acquire the underlying lock. This method calls the corresponding method on "
959
1002
"the underlying lock; the return value is whatever that method returns."
960
1003
msgstr ""
961
1004
962
- #: ../../library/threading.rst:751
1005
+ #: ../../library/threading.rst:778
963
1006
msgid ""
964
1007
"Release the underlying lock. This method calls the corresponding method on "
965
1008
"the underlying lock; there is no return value."
966
1009
msgstr ""
967
1010
968
- #: ../../library/threading.rst:756
1011
+ #: ../../library/threading.rst:783
969
1012
msgid ""
970
1013
"Wait until notified or until a timeout occurs. If the calling thread has not "
971
1014
"acquired the lock when this method is called, a :exc:`RuntimeError` is "
972
1015
"raised."
973
1016
msgstr ""
974
1017
975
- #: ../../library/threading.rst:760
1018
+ #: ../../library/threading.rst:787
976
1019
msgid ""
977
1020
"This method releases the underlying lock, and then blocks until it is "
978
1021
"awakened by a :meth:`notify` or :meth:`notify_all` call for the same "
979
1022
"condition variable in another thread, or until the optional timeout occurs. "
980
1023
"Once awakened or timed out, it re-acquires the lock and returns."
981
1024
msgstr ""
982
1025
983
- #: ../../library/threading.rst:765
1026
+ #: ../../library/threading.rst:792
984
1027
msgid ""
985
1028
"When the *timeout* argument is present and not ``None``, it should be a "
986
1029
"floating point number specifying a timeout for the operation in seconds (or "
987
1030
"fractions thereof)."
988
1031
msgstr ""
989
1032
990
- #: ../../library/threading.rst:769
1033
+ #: ../../library/threading.rst:796
991
1034
msgid ""
992
1035
"When the underlying lock is an :class:`RLock`, it is not released using its :"
993
1036
"meth:`release` method, since this may not actually unlock the lock when it "
@@ -997,97 +1040,97 @@ msgid ""
997
1040
"used to restore the recursion level when the lock is reacquired."
998
1041
msgstr ""
999
1042
1000
- #: ../../library/threading.rst:777
1043
+ #: ../../library/threading.rst:804
1001
1044
msgid ""
1002
1045
"The return value is ``True`` unless a given *timeout* expired, in which case "
1003
1046
"it is ``False``."
1004
1047
msgstr ""
1005
1048
1006
- #: ../../library/threading.rst:780 ../../library/threading.rst:996
1049
+ #: ../../library/threading.rst:807 ../../library/threading.rst:1023
1007
1050
msgid "Previously, the method always returned ``None``."
1008
1051
msgstr ""
1009
1052
1010
- #: ../../library/threading.rst:785
1053
+ #: ../../library/threading.rst:812
1011
1054
msgid ""
1012
1055
"Wait until a condition evaluates to true. *predicate* should be a callable "
1013
1056
"which result will be interpreted as a boolean value. A *timeout* may be "
1014
1057
"provided giving the maximum time to wait."
1015
1058
msgstr ""
1016
1059
1017
- #: ../../library/threading.rst:789
1060
+ #: ../../library/threading.rst:816
1018
1061
msgid ""
1019
1062
"This utility method may call :meth:`wait` repeatedly until the predicate is "
1020
1063
"satisfied, or until a timeout occurs. The return value is the last return "
1021
1064
"value of the predicate and will evaluate to ``False`` if the method timed "
1022
1065
"out."
1023
1066
msgstr ""
1024
1067
1025
- #: ../../library/threading.rst:794
1068
+ #: ../../library/threading.rst:821
1026
1069
msgid ""
1027
1070
"Ignoring the timeout feature, calling this method is roughly equivalent to "
1028
1071
"writing::"
1029
1072
msgstr ""
1030
1073
1031
- #: ../../library/threading.rst:800
1074
+ #: ../../library/threading.rst:827
1032
1075
msgid ""
1033
1076
"Therefore, the same rules apply as with :meth:`wait`: The lock must be held "
1034
1077
"when called and is re-acquired on return. The predicate is evaluated with "
1035
1078
"the lock held."
1036
1079
msgstr ""
1037
1080
1038
- #: ../../library/threading.rst:808
1081
+ #: ../../library/threading.rst:835
1039
1082
msgid ""
1040
1083
"By default, wake up one thread waiting on this condition, if any. If the "
1041
1084
"calling thread has not acquired the lock when this method is called, a :exc:"
1042
1085
"`RuntimeError` is raised."
1043
1086
msgstr ""
1044
1087
1045
- #: ../../library/threading.rst:812
1088
+ #: ../../library/threading.rst:839
1046
1089
msgid ""
1047
1090
"This method wakes up at most *n* of the threads waiting for the condition "
1048
1091
"variable; it is a no-op if no threads are waiting."
1049
1092
msgstr ""
1050
1093
1051
- #: ../../library/threading.rst:815
1094
+ #: ../../library/threading.rst:842
1052
1095
msgid ""
1053
1096
"The current implementation wakes up exactly *n* threads, if at least *n* "
1054
1097
"threads are waiting. However, it's not safe to rely on this behavior. A "
1055
1098
"future, optimized implementation may occasionally wake up more than *n* "
1056
1099
"threads."
1057
1100
msgstr ""
1058
1101
1059
- #: ../../library/threading.rst:820
1102
+ #: ../../library/threading.rst:847
1060
1103
msgid ""
1061
1104
"Note: an awakened thread does not actually return from its :meth:`wait` call "
1062
1105
"until it can reacquire the lock. Since :meth:`notify` does not release the "
1063
1106
"lock, its caller should."
1064
1107
msgstr ""
1065
1108
1066
- #: ../../library/threading.rst:826
1109
+ #: ../../library/threading.rst:853
1067
1110
msgid ""
1068
1111
"Wake up all threads waiting on this condition. This method acts like :meth:"
1069
1112
"`notify`, but wakes up all waiting threads instead of one. If the calling "
1070
1113
"thread has not acquired the lock when this method is called, a :exc:"
1071
1114
"`RuntimeError` is raised."
1072
1115
msgstr ""
1073
1116
1074
- #: ../../library/threading.rst:831
1117
+ #: ../../library/threading.rst:858
1075
1118
msgid "The method ``notifyAll`` is a deprecated alias for this method."
1076
1119
msgstr ""
1077
1120
1078
- #: ../../library/threading.rst:837
1121
+ #: ../../library/threading.rst:864
1079
1122
msgid "Semaphore Objects"
1080
1123
msgstr ""
1081
1124
1082
- #: ../../library/threading.rst:839
1125
+ #: ../../library/threading.rst:866
1083
1126
msgid ""
1084
1127
"This is one of the oldest synchronization primitives in the history of "
1085
1128
"computer science, invented by the early Dutch computer scientist Edsger W. "
1086
1129
"Dijkstra (he used the names ``P()`` and ``V()`` instead of :meth:`~Semaphore."
1087
1130
"acquire` and :meth:`~Semaphore.release`)."
1088
1131
msgstr ""
1089
1132
1090
- #: ../../library/threading.rst:844
1133
+ #: ../../library/threading.rst:871
1091
1134
msgid ""
1092
1135
"A semaphore manages an internal counter which is decremented by each :meth:"
1093
1136
"`~Semaphore.acquire` call and incremented by each :meth:`~Semaphore.release` "
@@ -1096,12 +1139,12 @@ msgid ""
1096
1139
"meth:`~Semaphore.release`."
1097
1140
msgstr ""
1098
1141
1099
- #: ../../library/threading.rst:850
1142
+ #: ../../library/threading.rst:877
1100
1143
msgid ""
1101
1144
"Semaphores also support the :ref:`context management protocol <with-locks>`."
1102
1145
msgstr ""
1103
1146
1104
- #: ../../library/threading.rst:855
1147
+ #: ../../library/threading.rst:882
1105
1148
msgid ""
1106
1149
"This class implements semaphore objects. A semaphore manages an atomic "
1107
1150
"counter representing the number of :meth:`release` calls minus the number "
@@ -1110,28 +1153,28 @@ msgid ""
1110
1153
"If not given, *value* defaults to 1."
1111
1154
msgstr ""
1112
1155
1113
- #: ../../library/threading.rst:861
1156
+ #: ../../library/threading.rst:888
1114
1157
msgid ""
1115
1158
"The optional argument gives the initial *value* for the internal counter; it "
1116
1159
"defaults to ``1``. If the *value* given is less than 0, :exc:`ValueError` is "
1117
1160
"raised."
1118
1161
msgstr ""
1119
1162
1120
- #: ../../library/threading.rst:870
1163
+ #: ../../library/threading.rst:897
1121
1164
msgid "Acquire a semaphore."
1122
1165
msgstr ""
1123
1166
1124
- #: ../../library/threading.rst:872
1167
+ #: ../../library/threading.rst:899
1125
1168
msgid "When invoked without arguments:"
1126
1169
msgstr ""
1127
1170
1128
- #: ../../library/threading.rst:874
1171
+ #: ../../library/threading.rst:901
1129
1172
msgid ""
1130
1173
"If the internal counter is larger than zero on entry, decrement it by one "
1131
1174
"and return ``True`` immediately."
1132
1175
msgstr ""
1133
1176
1134
- #: ../../library/threading.rst:876
1177
+ #: ../../library/threading.rst:903
1135
1178
msgid ""
1136
1179
"If the internal counter is zero on entry, block until awoken by a call to :"
1137
1180
"meth:`~Semaphore.release`. Once awoken (and the counter is greater than 0), "
@@ -1140,32 +1183,32 @@ msgid ""
1140
1183
"threads are awoken should not be relied on."
1141
1184
msgstr ""
1142
1185
1143
- #: ../../library/threading.rst:882
1186
+ #: ../../library/threading.rst:909
1144
1187
msgid ""
1145
1188
"When invoked with *blocking* set to ``False``, do not block. If a call "
1146
1189
"without an argument would block, return ``False`` immediately; otherwise, do "
1147
1190
"the same thing as when called without arguments, and return ``True``."
1148
1191
msgstr ""
1149
1192
1150
- #: ../../library/threading.rst:886
1193
+ #: ../../library/threading.rst:913
1151
1194
msgid ""
1152
1195
"When invoked with a *timeout* other than ``None``, it will block for at most "
1153
1196
"*timeout* seconds. If acquire does not complete successfully in that "
1154
1197
"interval, return ``False``. Return ``True`` otherwise."
1155
1198
msgstr ""
1156
1199
1157
- #: ../../library/threading.rst:895
1200
+ #: ../../library/threading.rst:922
1158
1201
msgid ""
1159
1202
"Release a semaphore, incrementing the internal counter by *n*. When it was "
1160
1203
"zero on entry and other threads are waiting for it to become larger than "
1161
1204
"zero again, wake up *n* of those threads."
1162
1205
msgstr ""
1163
1206
1164
- #: ../../library/threading.rst:899
1207
+ #: ../../library/threading.rst:926
1165
1208
msgid "Added the *n* parameter to release multiple waiting threads at once."
1166
1209
msgstr ""
1167
1210
1168
- #: ../../library/threading.rst:905
1211
+ #: ../../library/threading.rst:932
1169
1212
msgid ""
1170
1213
"Class implementing bounded semaphore objects. A bounded semaphore checks to "
1171
1214
"make sure its current value doesn't exceed its initial value. If it does, :"
@@ -1174,79 +1217,79 @@ msgid ""
1174
1217
"times it's a sign of a bug. If not given, *value* defaults to 1."
1175
1218
msgstr ""
1176
1219
1177
- #: ../../library/threading.rst:918
1220
+ #: ../../library/threading.rst:945
1178
1221
msgid ":class:`Semaphore` Example"
1179
1222
msgstr ":class:`Semaphore` 範例"
1180
1223
1181
- #: ../../library/threading.rst:920
1224
+ #: ../../library/threading.rst:947
1182
1225
msgid ""
1183
1226
"Semaphores are often used to guard resources with limited capacity, for "
1184
1227
"example, a database server. In any situation where the size of the resource "
1185
1228
"is fixed, you should use a bounded semaphore. Before spawning any worker "
1186
1229
"threads, your main thread would initialize the semaphore::"
1187
1230
msgstr ""
1188
1231
1189
- #: ../../library/threading.rst:929
1232
+ #: ../../library/threading.rst:956
1190
1233
msgid ""
1191
1234
"Once spawned, worker threads call the semaphore's acquire and release "
1192
1235
"methods when they need to connect to the server::"
1193
1236
msgstr ""
1194
1237
1195
- #: ../../library/threading.rst:939
1238
+ #: ../../library/threading.rst:966
1196
1239
msgid ""
1197
1240
"The use of a bounded semaphore reduces the chance that a programming error "
1198
1241
"which causes the semaphore to be released more than it's acquired will go "
1199
1242
"undetected."
1200
1243
msgstr ""
1201
1244
1202
- #: ../../library/threading.rst:946
1245
+ #: ../../library/threading.rst:973
1203
1246
msgid "Event Objects"
1204
1247
msgstr ""
1205
1248
1206
- #: ../../library/threading.rst:948
1249
+ #: ../../library/threading.rst:975
1207
1250
msgid ""
1208
1251
"This is one of the simplest mechanisms for communication between threads: "
1209
1252
"one thread signals an event and other threads wait for it."
1210
1253
msgstr ""
1211
1254
1212
- #: ../../library/threading.rst:951
1255
+ #: ../../library/threading.rst:978
1213
1256
msgid ""
1214
1257
"An event object manages an internal flag that can be set to true with the :"
1215
1258
"meth:`~Event.set` method and reset to false with the :meth:`~Event.clear` "
1216
1259
"method. The :meth:`~Event.wait` method blocks until the flag is true."
1217
1260
msgstr ""
1218
1261
1219
- #: ../../library/threading.rst:958
1262
+ #: ../../library/threading.rst:985
1220
1263
msgid ""
1221
1264
"Class implementing event objects. An event manages a flag that can be set "
1222
1265
"to true with the :meth:`~Event.set` method and reset to false with the :meth:"
1223
1266
"`clear` method. The :meth:`wait` method blocks until the flag is true. The "
1224
1267
"flag is initially false."
1225
1268
msgstr ""
1226
1269
1227
- #: ../../library/threading.rst:968
1270
+ #: ../../library/threading.rst:995
1228
1271
msgid "Return ``True`` if and only if the internal flag is true."
1229
1272
msgstr ""
1230
1273
1231
- #: ../../library/threading.rst:970
1274
+ #: ../../library/threading.rst:997
1232
1275
msgid "The method ``isSet`` is a deprecated alias for this method."
1233
1276
msgstr ""
1234
1277
1235
- #: ../../library/threading.rst:974
1278
+ #: ../../library/threading.rst:1001
1236
1279
msgid ""
1237
1280
"Set the internal flag to true. All threads waiting for it to become true are "
1238
1281
"awakened. Threads that call :meth:`wait` once the flag is true will not "
1239
1282
"block at all."
1240
1283
msgstr ""
1241
1284
1242
- #: ../../library/threading.rst:980
1285
+ #: ../../library/threading.rst:1007
1243
1286
msgid ""
1244
1287
"Reset the internal flag to false. Subsequently, threads calling :meth:`wait` "
1245
1288
"will block until :meth:`.set` is called to set the internal flag to true "
1246
1289
"again."
1247
1290
msgstr ""
1248
1291
1249
- #: ../../library/threading.rst:986
1292
+ #: ../../library/threading.rst:1013
1250
1293
msgid ""
1251
1294
"Block as long as the internal flag is false and the timeout, if given, has "
1252
1295
"not expired. The return value represents the reason that this blocking "
@@ -1255,26 +1298,26 @@ msgid ""
1255
1298
"become true within the given wait time."
1256
1299
msgstr ""
1257
1300
1258
- #: ../../library/threading.rst:992
1301
+ #: ../../library/threading.rst:1019
1259
1302
msgid ""
1260
1303
"When the timeout argument is present and not ``None``, it should be a "
1261
1304
"floating point number specifying a timeout for the operation in seconds, or "
1262
1305
"fractions thereof."
1263
1306
msgstr ""
1264
1307
1265
- #: ../../library/threading.rst:1003
1308
+ #: ../../library/threading.rst:1030
1266
1309
msgid "Timer Objects"
1267
1310
msgstr ""
1268
1311
1269
- #: ../../library/threading.rst:1005
1312
+ #: ../../library/threading.rst:1032
1270
1313
msgid ""
1271
1314
"This class represents an action that should be run only after a certain "
1272
1315
"amount of time has passed --- a timer. :class:`Timer` is a subclass of :"
1273
1316
"class:`Thread` and as such also functions as an example of creating custom "
1274
1317
"threads."
1275
1318
msgstr ""
1276
1319
1277
- #: ../../library/threading.rst:1009
1320
+ #: ../../library/threading.rst:1036
1278
1321
msgid ""
1279
1322
"Timers are started, as with threads, by calling their :meth:`Timer.start "
1280
1323
"<Thread.start>` method. The timer can be stopped (before its action has "
@@ -1283,32 +1326,32 @@ msgid ""
1283
1326
"interval specified by the user."
1284
1327
msgstr ""
1285
1328
1286
- #: ../../library/threading.rst:1015
1329
+ #: ../../library/threading.rst:1042
1287
1330
msgid "For example::"
1288
1331
msgstr ""
1289
1332
"舉例來說:\n"
1290
1333
"\n"
1291
1334
"::"
1292
1335
1293
- #: ../../library/threading.rst:1026
1336
+ #: ../../library/threading.rst:1053
1294
1337
msgid ""
1295
1338
"Create a timer that will run *function* with arguments *args* and keyword "
1296
1339
"arguments *kwargs*, after *interval* seconds have passed. If *args* is "
1297
1340
"``None`` (the default) then an empty list will be used. If *kwargs* is "
1298
1341
"``None`` (the default) then an empty dict will be used."
1299
1342
msgstr ""
1300
1343
1301
- #: ../../library/threading.rst:1036
1344
+ #: ../../library/threading.rst:1063
1302
1345
msgid ""
1303
1346
"Stop the timer, and cancel the execution of the timer's action. This will "
1304
1347
"only work if the timer is still in its waiting stage."
1305
1348
msgstr ""
1306
1349
1307
- #: ../../library/threading.rst:1041
1350
+ #: ../../library/threading.rst:1068
1308
1351
msgid "Barrier Objects"
1309
1352
msgstr ""
1310
1353
1311
- #: ../../library/threading.rst:1045
1354
+ #: ../../library/threading.rst:1072
1312
1355
msgid ""
1313
1356
"This class provides a simple synchronization primitive for use by a fixed "
1314
1357
"number of threads that need to wait for each other. Each of the threads "
@@ -1317,108 +1360,108 @@ msgid ""
1317
1360
"calls. At this point, the threads are released simultaneously."
1318
1361
msgstr ""
1319
1362
1320
- #: ../../library/threading.rst:1051
1363
+ #: ../../library/threading.rst:1078
1321
1364
msgid ""
1322
1365
"The barrier can be reused any number of times for the same number of threads."
1323
1366
msgstr ""
1324
1367
1325
- #: ../../library/threading.rst:1053
1368
+ #: ../../library/threading.rst:1080
1326
1369
msgid ""
1327
1370
"As an example, here is a simple way to synchronize a client and server "
1328
1371
"thread::"
1329
1372
msgstr ""
1330
1373
1331
- #: ../../library/threading.rst:1073
1374
+ #: ../../library/threading.rst:1100
1332
1375
msgid ""
1333
1376
"Create a barrier object for *parties* number of threads. An *action*, when "
1334
1377
"provided, is a callable to be called by one of the threads when they are "
1335
1378
"released. *timeout* is the default timeout value if none is specified for "
1336
1379
"the :meth:`wait` method."
1337
1380
msgstr ""
1338
1381
1339
- #: ../../library/threading.rst:1080
1382
+ #: ../../library/threading.rst:1107
1340
1383
msgid ""
1341
1384
"Pass the barrier. When all the threads party to the barrier have called "
1342
1385
"this function, they are all released simultaneously. If a *timeout* is "
1343
1386
"provided, it is used in preference to any that was supplied to the class "
1344
1387
"constructor."
1345
1388
msgstr ""
1346
1389
1347
- #: ../../library/threading.rst:1085
1390
+ #: ../../library/threading.rst:1112
1348
1391
msgid ""
1349
1392
"The return value is an integer in the range 0 to *parties* -- 1, different "
1350
1393
"for each thread. This can be used to select a thread to do some special "
1351
1394
"housekeeping, e.g.::"
1352
1395
msgstr ""
1353
1396
1354
- #: ../../library/threading.rst:1094
1397
+ #: ../../library/threading.rst:1121
1355
1398
msgid ""
1356
1399
"If an *action* was provided to the constructor, one of the threads will have "
1357
1400
"called it prior to being released. Should this call raise an error, the "
1358
1401
"barrier is put into the broken state."
1359
1402
msgstr ""
1360
1403
1361
- #: ../../library/threading.rst:1098
1404
+ #: ../../library/threading.rst:1125
1362
1405
msgid "If the call times out, the barrier is put into the broken state."
1363
1406
msgstr ""
1364
1407
1365
- #: ../../library/threading.rst:1100
1408
+ #: ../../library/threading.rst:1127
1366
1409
msgid ""
1367
1410
"This method may raise a :class:`BrokenBarrierError` exception if the barrier "
1368
1411
"is broken or reset while a thread is waiting."
1369
1412
msgstr ""
1370
1413
1371
- #: ../../library/threading.rst:1105
1414
+ #: ../../library/threading.rst:1132
1372
1415
msgid ""
1373
1416
"Return the barrier to the default, empty state. Any threads waiting on it "
1374
1417
"will receive the :class:`BrokenBarrierError` exception."
1375
1418
msgstr ""
1376
1419
1377
- #: ../../library/threading.rst:1108
1420
+ #: ../../library/threading.rst:1135
1378
1421
msgid ""
1379
1422
"Note that using this function may require some external synchronization if "
1380
1423
"there are other threads whose state is unknown. If a barrier is broken it "
1381
1424
"may be better to just leave it and create a new one."
1382
1425
msgstr ""
1383
1426
1384
- #: ../../library/threading.rst:1114
1427
+ #: ../../library/threading.rst:1141
1385
1428
msgid ""
1386
1429
"Put the barrier into a broken state. This causes any active or future calls "
1387
1430
"to :meth:`wait` to fail with the :class:`BrokenBarrierError`. Use this for "
1388
1431
"example if one of the threads needs to abort, to avoid deadlocking the "
1389
1432
"application."
1390
1433
msgstr ""
1391
1434
1392
- #: ../../library/threading.rst:1119
1435
+ #: ../../library/threading.rst:1146
1393
1436
msgid ""
1394
1437
"It may be preferable to simply create the barrier with a sensible *timeout* "
1395
1438
"value to automatically guard against one of the threads going awry."
1396
1439
msgstr ""
1397
1440
1398
- #: ../../library/threading.rst:1125
1441
+ #: ../../library/threading.rst:1152
1399
1442
msgid "The number of threads required to pass the barrier."
1400
1443
msgstr ""
1401
1444
1402
- #: ../../library/threading.rst:1129
1445
+ #: ../../library/threading.rst:1156
1403
1446
msgid "The number of threads currently waiting in the barrier."
1404
1447
msgstr ""
1405
1448
1406
- #: ../../library/threading.rst:1133
1449
+ #: ../../library/threading.rst:1160
1407
1450
msgid "A boolean that is ``True`` if the barrier is in the broken state."
1408
1451
msgstr ""
1409
1452
1410
- #: ../../library/threading.rst:1138
1453
+ #: ../../library/threading.rst:1165
1411
1454
msgid ""
1412
1455
"This exception, a subclass of :exc:`RuntimeError`, is raised when the :class:"
1413
1456
"`Barrier` object is reset or broken."
1414
1457
msgstr ""
1415
1458
1416
- #: ../../library/threading.rst:1145
1459
+ #: ../../library/threading.rst:1172
1417
1460
msgid ""
1418
1461
"Using locks, conditions, and semaphores in the :keyword:`!with` statement"
1419
1462
msgstr ""
1420
1463
1421
- #: ../../library/threading.rst:1147
1464
+ #: ../../library/threading.rst:1174
1422
1465
msgid ""
1423
1466
"All of the objects provided by this module that have ``acquire`` and "
1424
1467
"``release`` methods can be used as context managers for a :keyword:`with` "
@@ -1427,11 +1470,11 @@ msgid ""
1427
1470
"following snippet::"
1428
1471
msgstr ""
1429
1472
1430
- #: ../../library/threading.rst:1156
1473
+ #: ../../library/threading.rst:1183
1431
1474
msgid "is equivalent to::"
1432
1475
msgstr ""
1433
1476
1434
- #: ../../library/threading.rst:1164
1477
+ #: ../../library/threading.rst:1191
1435
1478
msgid ""
1436
1479
"Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`, :class:"
1437
1480
"`Semaphore`, and :class:`BoundedSemaphore` objects may be used as :keyword:"
0 commit comments