multithreading - Python : Creating a socket in a thread -


i trying create socket in thread, unable so. code is

#!/usr/bin/env python   import threading import socket  class test1():     def serve(self):         host = ''         port = 9999         th_obj = threading.thread(target = self.thread_method, args = (host,port))         th_obj.daemon = true         th_obj.start()      def thread_method(self,host,port):         sock = socket.socket(socket.af_inet,socket.sock_stream)         sock.setsockopt(socket.sol_socket, socket.so_reuseaddr,1)         sock.bind(('',9999))         sock.listen(5)         while true:             connection, addr = sock.accept()             connection.settimeout(60)             while true:                 data = connection.recv(2048)                 t = open('file.txt', 'a')                 t.write(data)  test1().serve() 

the problem script won't when set daemon = true while working without it.

how can solve problem. essential me demonize it.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -