-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented signal handling on the server and client scripts. The applications detect three signals: SIGINT, SIGQUIT and SIGTSTP. On any signal, the sockets are closed and object deleted.
- Loading branch information
1 parent
8464dba
commit c5efdf4
Showing
2 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
from modules.Streamer import Streamer | ||
from modules.Recorder import Recorder | ||
import sys, signal | ||
|
||
recorder = Recorder(0) | ||
stream = Streamer('127.0.0.1', 5005, recorder) #35.204.145.0 | ||
|
||
# SIGNAL HANDLING | ||
def receive_signal(signal_number, frame): | ||
global stream, recorder | ||
del stream | ||
print("\nStreamer released.") | ||
del recorder | ||
print("Recorder released.") | ||
print("Application exited.") | ||
sys.exit() | ||
|
||
def main(): | ||
recorder = Recorder(0) | ||
stream = Streamer('127.0.0.1', 5005, recorder) #35.204.145.0 | ||
stream.send_to_server() | ||
|
||
if __name__ == "__main__": | ||
signal.signal(signal.SIGINT, receive_signal) | ||
signal.signal(signal.SIGQUIT, receive_signal) | ||
signal.signal(signal.SIGTSTP, receive_signal) | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters