„README.md“ ändern
This commit is contained in:
parent
5b390b2083
commit
f963e41c52
28
README.md
28
README.md
|
@ -1,11 +1,12 @@
|
|||
timeout-interrupt
|
||||
=================
|
||||
|
||||
Works like ruby's timeout, but interrupts every call, also syscalls, which blocks the hole ruby-process.
|
||||
Works like ruby's timeout, but interrupts *every call*, also syscalls, which blocks the hole ruby-process.
|
||||
|
||||
It uses POSIX's alarm and traps ALRM-signals.
|
||||
|
||||
Known limitations bacause of alarm and ALRM are, that you can not use alarm or trap ALRM.
|
||||
Known limitations bacause of alarm and ALRM are, that you can not use alarm or trap ALRM in the same time.
|
||||
|
||||
|
||||
Scopes
|
||||
======
|
||||
|
@ -23,27 +24,30 @@ If you want to know, which was raised, you need custom exceptions:
|
|||
|
||||
class CustomErrorWillBeRaised <Exception
|
||||
end
|
||||
class CustomErrorNotRaise <Exception
|
||||
class CustomErrorNotRaised <Exception
|
||||
end
|
||||
include TimeoutInterrupt
|
||||
timeout( 1, CustomErrorWillBeRaised) { # Will be raised again
|
||||
timeout( 10, CustomErrorNotRaise) { sleep 2 } # Will not be raised
|
||||
timeout( 10, CustomErrorNotRaised) { sleep 2 } # Will not be raised
|
||||
}
|
||||
|
||||
|
||||
Problems
|
||||
========
|
||||
|
||||
Memory-Leaks or no clean up
|
||||
---------------------------
|
||||
Memory-Leaks and missing clean up
|
||||
---------------------------------
|
||||
|
||||
Do not forget, syscall can have allocated memory.
|
||||
If you interrupt a call, which can not free his allocations, you will have a memory leak.
|
||||
If it opens a file, reads it and closes it and while it reads, a time out occurs, the file will not be closed.
|
||||
Syscalls can allocate memory.
|
||||
If you interrupt a syscall, which then cannot free his allocations, it will result in a memory leak.
|
||||
If it opens a file, while it reads, a time out occurs, the file will not automatically be closed.
|
||||
|
||||
So, use it only, if your process did not live any longer or if you call something, which never allocate mem or opens a file.
|
||||
So, you should only use it, if your process will die after interrupt or if you are sure, that your call never allocate memory or opens a file.
|
||||
You could also publish informations about opened files, that it could be cleaned up later.
|
||||
|
||||
Every time, a process dies, all his memory will be freed and every file will be closed, so let your process die and you should be safe.
|
||||
|
||||
|
||||
Exception-handling
|
||||
------------------
|
||||
|
||||
|
@ -60,11 +64,11 @@ Timeouts can break your exception-handling! You should not handling exception wh
|
|||
end
|
||||
}
|
||||
|
||||
Same happens, if clean\_up will raise an exception.
|
||||
Same happens, if clean\_up will raise an exception, so handle it in the same way.
|
||||
|
||||
And same problem you have with ruby's `Timeout.timeout`.
|
||||
|
||||
Copyleft
|
||||
=========
|
||||
|
||||
Copyright (c) 2021 Denis Knauf. See LICENSE.txt for further details.
|
||||
Copyright (c) 2021 Denis Knauf. See LICENSE.txt for further details.
|
Loading…
Reference in a new issue