在下面的代码中,我启动了一个具有一些辅助功能的进程。
def listener(ttl, port):
print "Started listenning on port: " + str(port) + " for: " + str(ttl) + " seconds."
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind(('localhost', port))
serversocket.listen(1)
time.sleep(ttl)
print "Finished listening on port: " + str(port)
def main():
thread1 = threading.Thread(target = listener, args = (20,5555))
thread1.start()
print thread1.get_ident()
thread1.join()
print "main completed"
如何获得thread1
的PID?
我在Ubuntu Linux 14.04上有所作为。