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
fd28502f
Kaydet (Commit)
fd28502f
authored
May 07, 2011
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closed resource leak in SysLogHandler.
üst
9c187786
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
31 deletions
+28
-31
handlers.py
Lib/logging/handlers.py
+1
-2
test_logging.py
Lib/test/test_logging.py
+27
-29
No files found.
Lib/logging/handlers.py
Dosyayı görüntüle @
fd28502f
...
@@ -756,8 +756,7 @@ class SysLogHandler(logging.Handler):
...
@@ -756,8 +756,7 @@ class SysLogHandler(logging.Handler):
"""
"""
Closes the socket.
Closes the socket.
"""
"""
if
self
.
unixsocket
:
self
.
socket
.
close
()
self
.
socket
.
close
()
logging
.
Handler
.
close
(
self
)
logging
.
Handler
.
close
(
self
)
def
mapPriority
(
self
,
levelName
):
def
mapPriority
(
self
,
levelName
):
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
fd28502f
...
@@ -3484,41 +3484,39 @@ class TimedRotatingFileHandlerTest(BaseFileTest):
...
@@ -3484,41 +3484,39 @@ class TimedRotatingFileHandlerTest(BaseFileTest):
def
test_rollover
(
self
):
def
test_rollover
(
self
):
fh
=
logging
.
handlers
.
TimedRotatingFileHandler
(
self
.
fn
,
'S'
,
fh
=
logging
.
handlers
.
TimedRotatingFileHandler
(
self
.
fn
,
'S'
,
backupCount
=
1
)
backupCount
=
1
)
try
:
r
=
logging
.
makeLogRecord
({
'msg'
:
'testing'
})
r
=
logging
.
makeLogRecord
({
'msg'
:
'testing'
})
fh
.
emit
(
r
)
fh
.
emit
(
r
)
self
.
assertLogFile
(
self
.
fn
)
self
.
assertLogFile
(
self
.
fn
)
time
.
sleep
(
1.0
)
time
.
sleep
(
1.0
)
fh
.
emit
(
r
)
fh
.
emit
(
r
)
fh
.
close
()
# At this point, we should have a recent rotated file which we
# At this point, we should have a recent rotated file which we
# can test for the existence of. However, in practice, on some
# can test for the existence of. However, in practice, on some
# machines which run really slowly, we don't know how far back
# machines which run really slowly, we don't know how far back
# in time to go to look for the log file. So, we go back a fair
# in time to go to look for the log file. So, we go back a fair
# bit, and stop as soon as we see a rotated file. In theory this
# bit, and stop as soon as we see a rotated file. In theory this
# could of course still fail, but the chances are lower.
# could of course still fail, but the chances are lower.
found
=
False
found
=
False
now
=
datetime
.
datetime
.
now
()
now
=
datetime
.
datetime
.
now
()
GO_BACK
=
2
*
60
# seconds
GO_BACK
=
2
*
60
# seconds
for
secs
in
range
(
1
,
GO_BACK
):
for
secs
in
range
(
1
,
GO_BACK
):
prev
=
now
-
datetime
.
timedelta
(
seconds
=
secs
)
prev
=
now
-
datetime
.
timedelta
(
seconds
=
secs
)
fn
=
self
.
fn
+
prev
.
strftime
(
".
%
Y-
%
m-
%
d_
%
H-
%
M-
%
S"
)
fn
=
self
.
fn
+
prev
.
strftime
(
".
%
Y-
%
m-
%
d_
%
H-
%
M-
%
S"
)
found
=
os
.
path
.
exists
(
fn
)
found
=
os
.
path
.
exists
(
fn
)
if
found
:
if
found
:
self
.
rmfiles
.
append
(
fn
)
self
.
rmfiles
.
append
(
fn
)
break
break
msg
=
'No rotated files found, went back
%
d seconds'
%
GO_BACK
msg
=
'No rotated files found, went back
%
d seconds'
%
GO_BACK
self
.
assertTrue
(
found
,
msg
=
msg
)
self
.
assertTrue
(
found
,
msg
=
msg
)
finally
:
fh
.
close
()
def
test_invalid
(
self
):
def
test_invalid
(
self
):
assertRaises
=
self
.
assertRaises
assertRaises
=
self
.
assertRaises
assertRaises
(
ValueError
,
logging
.
handlers
.
TimedRotatingFileHandler
,
assertRaises
(
ValueError
,
logging
.
handlers
.
TimedRotatingFileHandler
,
self
.
fn
,
'X'
)
self
.
fn
,
'X'
,
delay
=
True
)
assertRaises
(
ValueError
,
logging
.
handlers
.
TimedRotatingFileHandler
,
assertRaises
(
ValueError
,
logging
.
handlers
.
TimedRotatingFileHandler
,
self
.
fn
,
'W'
)
self
.
fn
,
'W'
,
delay
=
True
)
assertRaises
(
ValueError
,
logging
.
handlers
.
TimedRotatingFileHandler
,
assertRaises
(
ValueError
,
logging
.
handlers
.
TimedRotatingFileHandler
,
self
.
fn
,
'W7'
)
self
.
fn
,
'W7'
,
delay
=
True
)
def
secs
(
**
kw
):
def
secs
(
**
kw
):
return
datetime
.
timedelta
(
**
kw
)
//
datetime
.
timedelta
(
seconds
=
1
)
return
datetime
.
timedelta
(
**
kw
)
//
datetime
.
timedelta
(
seconds
=
1
)
...
...
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