Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
121a1c4e
Kaydet (Commit)
121a1c4e
authored
Eyl 08, 2010
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
logging: Added QueueHandler.
üst
febeb00e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
0 deletions
+55
-0
logging.rst
Doc/library/logging.rst
+0
-0
handlers.py
Lib/logging/handlers.py
+52
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/logging.rst
Dosyayı görüntüle @
121a1c4e
This diff is collapsed.
Click to expand it.
Lib/logging/handlers.py
Dosyayı görüntüle @
121a1c4e
...
...
@@ -1134,3 +1134,55 @@ class MemoryHandler(BufferingHandler):
self
.
flush
()
self
.
target
=
None
BufferingHandler
.
close
(
self
)
class
QueueHandler
(
logging
.
Handler
):
"""
This handler sends events to a queue. Typically, it would be used together
with a multiprocessing Queue to centralise logging to file in one process
(in a multi-process application), so as to avoid file write contention
between processes.
This code is new in Python 3.2, but this class can be copy pasted into
user code for use with earlier Python versions.
"""
def
__init__
(
self
,
queue
):
"""
Initialise an instance, using the passed queue.
"""
logging
.
Handler
.
__init__
(
self
)
self
.
queue
=
queue
def
enqueue
(
self
,
record
):
"""
Enqueue a record.
The base implementation uses put_nowait. You may want to override
this method if you want to use blocking, timeouts or custom queue
implementations.
"""
self
.
queue
.
put_nowait
(
record
)
def
emit
(
self
,
record
):
"""
Emit a record.
Writes the LogRecord to the queue, preparing it for pickling first.
"""
try
:
# The format operation gets traceback text into record.exc_text
# (if there's exception data), and also puts the message into
# record.message. We can then use this to replace the original
# msg + args, as these might be unpickleable. We also zap the
# exc_info attribute, as it's no longer needed and, if not None,
# will typically not be pickleable.
self
.
format
(
record
)
record
.
msg
=
record
.
message
record
.
args
=
None
record
.
exc_info
=
None
self
.
enqueue
(
record
)
except
(
KeyboardInterrupt
,
SystemExit
):
raise
except
:
self
.
handleError
(
record
)
Misc/NEWS
Dosyayı görüntüle @
121a1c4e
...
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
-------
- Logging: Added QueueHandler class to facilitate logging usage with
multiprocessing.
- Issue #9707: Rewritten reference implementation of threading.local which
is friendlier towards reference cycles. This change is not normally
visible since an optimized C implementation (_thread._local) is used
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment