<s> import threading <EOL> class DaemonServer ( object ) : <EOL> """<STR_LIT>""" <EOL> def __enter__ ( self ) : <EOL> thread = threading . Thread ( target = self . serve_forever ) <EOL> thread . daemon = True <EOL> thread . start ( ) <EOL> return self <EOL> def __exit__ ( self , unused_exc_type , unused_exc_val , unused_exc_tb ) : <EOL> self . cleanup ( ) </s>
