commit 4f27b4845615cf580f169a504aea99a8f2a4aa8f
parent d62f3f6e85bd61021b575b7a6110d0c641e96bd8
Author: Thomas Frössman <thomasf@jossystem.se>
Date: Sun, 3 Nov 2019 18:37:27 +0100
dev: ran black on python sample file
Diffstat:
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/minimal-init/test-files/python.py b/minimal-init/test-files/python.py
@@ -1,13 +1,15 @@
# test python (sample from offlineimap)
+
class ExitNotifyThread(Thread):
"""This class is designed to alert a "monitor" to the fact that a thread has
exited and to provide for the ability for it to find out why."""
+
def run(self):
global exitthreads, profiledir
self.threadid = thread.get_ident()
try:
- if not profiledir: # normal case
+ if not profiledir: # normal case
Thread.run(self)
else:
try:
@@ -19,18 +21,23 @@ class ExitNotifyThread(Thread):
prof = prof.runctx("Thread.run(self)", globals(), locals())
except SystemExit:
pass
- prof.dump_stats( \
- profiledir + "/" + str(self.threadid) + "_" + \
- self.getName() + ".prof")
+ prof.dump_stats(
+ profiledir
+ + "/"
+ + str(self.threadid)
+ + "_"
+ + self.getName()
+ + ".prof"
+ )
except:
- self.setExitCause('EXCEPTION')
+ self.setExitCause("EXCEPTION")
if sys:
self.setExitException(sys.exc_info()[1])
tb = traceback.format_exc()
self.setExitStackTrace(tb)
else:
- self.setExitCause('NORMAL')
- if not hasattr(self, 'exitmessage'):
+ self.setExitCause("NORMAL")
+ if not hasattr(self, "exitmessage"):
self.setExitMessage(None)
if exitthreads:
@@ -38,19 +45,24 @@ class ExitNotifyThread(Thread):
def setExitCause(self, cause):
self.exitcause = cause
+
def getExitCause(self):
"""Returns the cause of the exit, one of:
'EXCEPTION' -- the thread aborted because of an exception
'NORMAL' -- normal termination."""
return self.exitcause
+
def setExitException(self, exc):
self.exitexception = exc
+
def getExitException(self):
"""If getExitCause() is 'EXCEPTION', holds the value from
sys.exc_info()[1] for this exception."""
return self.exitexception
+
def setExitStackTrace(self, st):
self.exitstacktrace = st
+
def getExitStackTrace(self):
"""If getExitCause() is 'EXCEPTION', returns a string representing
the stack trace for this exception."""
@@ -60,6 +72,7 @@ class ExitNotifyThread(Thread):
getExitMessage. This message may be any object or type except
None."""
self.exitmessage = msg
+
def getExitMessage(self):
"""For any exit cause, returns the message previously set by
a call to setExitMessage(), or None if there was no such message