Python signal.ITIMER_PROF Examples
The following are 24
code examples of signal.ITIMER_PROF().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
signal
, or try the search function
.
Example #1
Source File: test_signal.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #2
Source File: test_signal.py From android_universal with MIT License | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.monotonic() while time.monotonic() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #3
Source File: test_signal.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.monotonic() while time.monotonic() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #4
Source File: test_signal.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #5
Source File: test_signal.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #6
Source File: test_signal.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.monotonic() while time.monotonic() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #7
Source File: test_signal.py From oss-ftp with MIT License | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #8
Source File: test_signal.py From BinderFilter with MIT License | 6 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) start_time = time.time() while time.time() - start_time < 60.0: # do some work _ = pow(12345, 67890, 10000019) if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer else: # Issue 8424 self.skipTest("timeout: likely cause: machine too slow or load too " "high") # profiling itimer should be (0.0, 0.0) now self.assertEqual(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #9
Source File: samplers.py From profiling with BSD 3-Clause "New" or "Revised" License | 6 votes |
def run(self, profiler): weak_profiler = weakref.proxy(profiler) handle = functools.partial(self.handle_signal, weak_profiler) t = self.interval with deferral() as defer: prev_handle = signal.signal(signal.SIGPROF, handle) if prev_handle == signal.SIG_DFL: # sometimes the process receives SIGPROF although the sampler # unsets the itimer. If the previous handler was SIG_DFL, the # process will crash when received SIGPROF. To prevent this # risk, it makes the process to ignore SIGPROF when it isn't # running if the previous handler was SIG_DFL. prev_handle = signal.SIG_IGN defer(signal.signal, signal.SIGPROF, prev_handle) prev_itimer = signal.setitimer(signal.ITIMER_PROF, t, t) defer(signal.setitimer, signal.ITIMER_PROF, *prev_itimer) yield
Example #10
Source File: test_signal.py From medicare-demo with Apache License 2.0 | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args)
Example #11
Source File: test_signal.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) for i in xrange(100000000): if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #12
Source File: test_signal.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args)
Example #13
Source File: scalene.py From scalene with Apache License 2.0 | 5 votes |
def set_timer_signal(use_wallclock_time: bool = False) -> None: """Set up timer signals for CPU profiling.""" if use_wallclock_time: Scalene.__cpu_timer_signal = signal.ITIMER_REAL else: Scalene.__cpu_timer_signal = signal.ITIMER_VIRTUAL # Now set the appropriate timer signal. if Scalene.__cpu_timer_signal == signal.ITIMER_REAL: Scalene.__cpu_signal = signal.SIGALRM elif Scalene.__cpu_timer_signal == signal.ITIMER_VIRTUAL: Scalene.__cpu_signal = signal.SIGVTALRM elif Scalene.__cpu_timer_signal == signal.ITIMER_PROF: # NOT SUPPORTED assert False, "ITIMER_PROF is not currently supported."
Example #14
Source File: test_signal.py From ironpython2 with Apache License 2.0 | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args)
Example #15
Source File: test_signal.py From android_universal with MIT License | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0)
Example #16
Source File: test_signal.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) for i in xrange(100000000): if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #17
Source File: test_signal.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args)
Example #18
Source File: test_signal.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_itimer_prof(self): self.itimer = signal.ITIMER_PROF signal.signal(signal.SIGPROF, self.sig_prof) signal.setitimer(self.itimer, 0.2, 0.2) for i in xrange(100000000): if signal.getitimer(self.itimer) == (0.0, 0.0): break # sig_prof handler stopped this itimer # profiling itimer should be (0.0, 0.0) now self.assertEquals(signal.getitimer(self.itimer), (0.0, 0.0)) # and the handler should have been called self.assertEqual(self.hndl_called, True)
Example #19
Source File: test_signal.py From BinderFilter with MIT License | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args)
Example #20
Source File: test_signal.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0)
Example #21
Source File: test_signal.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args)
Example #22
Source File: test_signal.py From oss-ftp with MIT License | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0) if test_support.verbose: print("SIGPROF handler invoked", args)
Example #23
Source File: test_signal.py From ironpython3 with Apache License 2.0 | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0)
Example #24
Source File: test_signal.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def sig_prof(self, *args): self.hndl_called = True signal.setitimer(signal.ITIMER_PROF, 0)