Keep Python COM local server listening open in paralallel while the main code runs
up vote
0
down vote
favorite
I am trying to build a COM server to get real time information. The problem is that all other functionalities stop while localserver is opened. The rest of the code just runs when the localserver is closed.
I have searched for solutions and failed trying multiprocessing, not because this wouldn't work, I guess because I suck. Anyway, I am stuck in this part.
import pythoncom
import win32com
from win32com.server import localserver
from multiprocessing import Process
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech', 'roger']
_readonly_attrs_ = ['roger']
_public_methods_ = ['talktome']
def __init__(self):
self.roger = 'roger'
self.speech = None
def talktome(self,speech):
self.speech = speech
print ('New speech received: ' + self.speech)
return self.roger
### ___ ###
def runserver(mess):
print(mess)
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
if __name__=='__main__':
pu = PythonUtilities
print ("Registering COM Server ")
win32com.server.register.UseCommandLine(pu)
# Fine so far.
# The problem starts here:
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code waiting for localserver be closed
# Experiment... Doesnt work:
#proc = Process(target=runserver, args = ('starting process',))
#proc.start()
#proc.join()
It's important to say that all messages sent from the client seem to be correctly displayed BUT ONLY AFTER I close the local server manually. I want to receive it in real time like a chat app. I mean, I want to keep the localserver opened and being able to work with the information received along the rest of the code.
python server com chat localserver
add a comment |
up vote
0
down vote
favorite
I am trying to build a COM server to get real time information. The problem is that all other functionalities stop while localserver is opened. The rest of the code just runs when the localserver is closed.
I have searched for solutions and failed trying multiprocessing, not because this wouldn't work, I guess because I suck. Anyway, I am stuck in this part.
import pythoncom
import win32com
from win32com.server import localserver
from multiprocessing import Process
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech', 'roger']
_readonly_attrs_ = ['roger']
_public_methods_ = ['talktome']
def __init__(self):
self.roger = 'roger'
self.speech = None
def talktome(self,speech):
self.speech = speech
print ('New speech received: ' + self.speech)
return self.roger
### ___ ###
def runserver(mess):
print(mess)
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
if __name__=='__main__':
pu = PythonUtilities
print ("Registering COM Server ")
win32com.server.register.UseCommandLine(pu)
# Fine so far.
# The problem starts here:
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code waiting for localserver be closed
# Experiment... Doesnt work:
#proc = Process(target=runserver, args = ('starting process',))
#proc.start()
#proc.join()
It's important to say that all messages sent from the client seem to be correctly displayed BUT ONLY AFTER I close the local server manually. I want to receive it in real time like a chat app. I mean, I want to keep the localserver opened and being able to work with the information received along the rest of the code.
python server com chat localserver
You're not supposed to register and serve at the same time as an out-of-process server will be started by pythonw.exe when requested. So first register your server and just do nothing more. See an example here: stackoverflow.com/questions/1054849/…
– Simon Mourier
Nov 12 at 8:53
@SimonMourier, I have already seen this post. Notice that the Rob's answer marked as solved. He explains that ...register.UseCommandLine() only registers a piece of code so much so that it can be accessed even when the server application is closed. Therefore, I need to keep this server running because I need to listen the client. That's why the ...localserver.serve (). And It works. The problem is that when I run the server, everything else waits the server's process ends. Just when I close the server's window manually the code above prints all the client's "speech". It should be real time.
– Eric Trevisani
Nov 12 at 19:12
I understood your question and I pointed to this answer precisely because it explains how to do it. You don't have to run your server and wait for something. You run it manually only for register and unregister. After than, it will be started by pythonw.exe when someone accesses it.
– Simon Mourier
Nov 13 at 8:31
@SimonMourier, yes. You are right. There is no need... register.UseCommandLine() ...localserver.serve() does it. Afterwards, I got a solution rewriting the localserver.serve() function and starting it in a new thread.
– Eric Trevisani
Nov 14 at 3:03
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to build a COM server to get real time information. The problem is that all other functionalities stop while localserver is opened. The rest of the code just runs when the localserver is closed.
I have searched for solutions and failed trying multiprocessing, not because this wouldn't work, I guess because I suck. Anyway, I am stuck in this part.
import pythoncom
import win32com
from win32com.server import localserver
from multiprocessing import Process
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech', 'roger']
_readonly_attrs_ = ['roger']
_public_methods_ = ['talktome']
def __init__(self):
self.roger = 'roger'
self.speech = None
def talktome(self,speech):
self.speech = speech
print ('New speech received: ' + self.speech)
return self.roger
### ___ ###
def runserver(mess):
print(mess)
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
if __name__=='__main__':
pu = PythonUtilities
print ("Registering COM Server ")
win32com.server.register.UseCommandLine(pu)
# Fine so far.
# The problem starts here:
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code waiting for localserver be closed
# Experiment... Doesnt work:
#proc = Process(target=runserver, args = ('starting process',))
#proc.start()
#proc.join()
It's important to say that all messages sent from the client seem to be correctly displayed BUT ONLY AFTER I close the local server manually. I want to receive it in real time like a chat app. I mean, I want to keep the localserver opened and being able to work with the information received along the rest of the code.
python server com chat localserver
I am trying to build a COM server to get real time information. The problem is that all other functionalities stop while localserver is opened. The rest of the code just runs when the localserver is closed.
I have searched for solutions and failed trying multiprocessing, not because this wouldn't work, I guess because I suck. Anyway, I am stuck in this part.
import pythoncom
import win32com
from win32com.server import localserver
from multiprocessing import Process
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech', 'roger']
_readonly_attrs_ = ['roger']
_public_methods_ = ['talktome']
def __init__(self):
self.roger = 'roger'
self.speech = None
def talktome(self,speech):
self.speech = speech
print ('New speech received: ' + self.speech)
return self.roger
### ___ ###
def runserver(mess):
print(mess)
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
if __name__=='__main__':
pu = PythonUtilities
print ("Registering COM Server ")
win32com.server.register.UseCommandLine(pu)
# Fine so far.
# The problem starts here:
localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code waiting for localserver be closed
# Experiment... Doesnt work:
#proc = Process(target=runserver, args = ('starting process',))
#proc.start()
#proc.join()
It's important to say that all messages sent from the client seem to be correctly displayed BUT ONLY AFTER I close the local server manually. I want to receive it in real time like a chat app. I mean, I want to keep the localserver opened and being able to work with the information received along the rest of the code.
python server com chat localserver
python server com chat localserver
asked Nov 12 at 0:01
Eric Trevisani
63
63
You're not supposed to register and serve at the same time as an out-of-process server will be started by pythonw.exe when requested. So first register your server and just do nothing more. See an example here: stackoverflow.com/questions/1054849/…
– Simon Mourier
Nov 12 at 8:53
@SimonMourier, I have already seen this post. Notice that the Rob's answer marked as solved. He explains that ...register.UseCommandLine() only registers a piece of code so much so that it can be accessed even when the server application is closed. Therefore, I need to keep this server running because I need to listen the client. That's why the ...localserver.serve (). And It works. The problem is that when I run the server, everything else waits the server's process ends. Just when I close the server's window manually the code above prints all the client's "speech". It should be real time.
– Eric Trevisani
Nov 12 at 19:12
I understood your question and I pointed to this answer precisely because it explains how to do it. You don't have to run your server and wait for something. You run it manually only for register and unregister. After than, it will be started by pythonw.exe when someone accesses it.
– Simon Mourier
Nov 13 at 8:31
@SimonMourier, yes. You are right. There is no need... register.UseCommandLine() ...localserver.serve() does it. Afterwards, I got a solution rewriting the localserver.serve() function and starting it in a new thread.
– Eric Trevisani
Nov 14 at 3:03
add a comment |
You're not supposed to register and serve at the same time as an out-of-process server will be started by pythonw.exe when requested. So first register your server and just do nothing more. See an example here: stackoverflow.com/questions/1054849/…
– Simon Mourier
Nov 12 at 8:53
@SimonMourier, I have already seen this post. Notice that the Rob's answer marked as solved. He explains that ...register.UseCommandLine() only registers a piece of code so much so that it can be accessed even when the server application is closed. Therefore, I need to keep this server running because I need to listen the client. That's why the ...localserver.serve (). And It works. The problem is that when I run the server, everything else waits the server's process ends. Just when I close the server's window manually the code above prints all the client's "speech". It should be real time.
– Eric Trevisani
Nov 12 at 19:12
I understood your question and I pointed to this answer precisely because it explains how to do it. You don't have to run your server and wait for something. You run it manually only for register and unregister. After than, it will be started by pythonw.exe when someone accesses it.
– Simon Mourier
Nov 13 at 8:31
@SimonMourier, yes. You are right. There is no need... register.UseCommandLine() ...localserver.serve() does it. Afterwards, I got a solution rewriting the localserver.serve() function and starting it in a new thread.
– Eric Trevisani
Nov 14 at 3:03
You're not supposed to register and serve at the same time as an out-of-process server will be started by pythonw.exe when requested. So first register your server and just do nothing more. See an example here: stackoverflow.com/questions/1054849/…
– Simon Mourier
Nov 12 at 8:53
You're not supposed to register and serve at the same time as an out-of-process server will be started by pythonw.exe when requested. So first register your server and just do nothing more. See an example here: stackoverflow.com/questions/1054849/…
– Simon Mourier
Nov 12 at 8:53
@SimonMourier, I have already seen this post. Notice that the Rob's answer marked as solved. He explains that ...register.UseCommandLine() only registers a piece of code so much so that it can be accessed even when the server application is closed. Therefore, I need to keep this server running because I need to listen the client. That's why the ...localserver.serve (). And It works. The problem is that when I run the server, everything else waits the server's process ends. Just when I close the server's window manually the code above prints all the client's "speech". It should be real time.
– Eric Trevisani
Nov 12 at 19:12
@SimonMourier, I have already seen this post. Notice that the Rob's answer marked as solved. He explains that ...register.UseCommandLine() only registers a piece of code so much so that it can be accessed even when the server application is closed. Therefore, I need to keep this server running because I need to listen the client. That's why the ...localserver.serve (). And It works. The problem is that when I run the server, everything else waits the server's process ends. Just when I close the server's window manually the code above prints all the client's "speech". It should be real time.
– Eric Trevisani
Nov 12 at 19:12
I understood your question and I pointed to this answer precisely because it explains how to do it. You don't have to run your server and wait for something. You run it manually only for register and unregister. After than, it will be started by pythonw.exe when someone accesses it.
– Simon Mourier
Nov 13 at 8:31
I understood your question and I pointed to this answer precisely because it explains how to do it. You don't have to run your server and wait for something. You run it manually only for register and unregister. After than, it will be started by pythonw.exe when someone accesses it.
– Simon Mourier
Nov 13 at 8:31
@SimonMourier, yes. You are right. There is no need... register.UseCommandLine() ...localserver.serve() does it. Afterwards, I got a solution rewriting the localserver.serve() function and starting it in a new thread.
– Eric Trevisani
Nov 14 at 3:03
@SimonMourier, yes. You are right. There is no need... register.UseCommandLine() ...localserver.serve() does it. Afterwards, I got a solution rewriting the localserver.serve() function and starting it in a new thread.
– Eric Trevisani
Nov 14 at 3:03
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
My problem was solved rewriting the localserver.serve() function and starting it in a new thread as the code below.
import pythoncom
from win32com.client import Dispatch # to get attributes
from win32com.server import register, factory
from threading import Thread
from queue import Queue
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech']
_public_methods_ = ['talktome']
queue_speech = Queue()
def talktome(self,speech):
self.queue_speech.put(speech)
print ('New speech received: ' + speech)
return 'roger'
### ___ ###
# use instead localserver.serve()
def runserver():
# added - multithread support
pythoncom.CoInitialize()
clsids = ['D9C54599-9011-4678-B1EB-A07FD272F0AF']
infos = factory.RegisterClassFactories(clsids)
# commented - from original localserver.serve() method
#pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())
pythoncom.CoResumeClassObjects()
pythoncom.PumpMessages()
factory.RevokeClassFactories( infos )
pythoncom.CoUninitialize()
if __name__=='__main__':
#use this
server_thread = Thread(target=runserver) # Process works as well
server_thread.start()
#instead this
#localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code now works in parallel
Also I have made some improvements like Queue to get data later. I hope it can help others.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254468%2fkeep-python-com-local-server-listening-open-in-paralallel-while-the-main-code-ru%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
My problem was solved rewriting the localserver.serve() function and starting it in a new thread as the code below.
import pythoncom
from win32com.client import Dispatch # to get attributes
from win32com.server import register, factory
from threading import Thread
from queue import Queue
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech']
_public_methods_ = ['talktome']
queue_speech = Queue()
def talktome(self,speech):
self.queue_speech.put(speech)
print ('New speech received: ' + speech)
return 'roger'
### ___ ###
# use instead localserver.serve()
def runserver():
# added - multithread support
pythoncom.CoInitialize()
clsids = ['D9C54599-9011-4678-B1EB-A07FD272F0AF']
infos = factory.RegisterClassFactories(clsids)
# commented - from original localserver.serve() method
#pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())
pythoncom.CoResumeClassObjects()
pythoncom.PumpMessages()
factory.RevokeClassFactories( infos )
pythoncom.CoUninitialize()
if __name__=='__main__':
#use this
server_thread = Thread(target=runserver) # Process works as well
server_thread.start()
#instead this
#localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code now works in parallel
Also I have made some improvements like Queue to get data later. I hope it can help others.
add a comment |
up vote
0
down vote
My problem was solved rewriting the localserver.serve() function and starting it in a new thread as the code below.
import pythoncom
from win32com.client import Dispatch # to get attributes
from win32com.server import register, factory
from threading import Thread
from queue import Queue
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech']
_public_methods_ = ['talktome']
queue_speech = Queue()
def talktome(self,speech):
self.queue_speech.put(speech)
print ('New speech received: ' + speech)
return 'roger'
### ___ ###
# use instead localserver.serve()
def runserver():
# added - multithread support
pythoncom.CoInitialize()
clsids = ['D9C54599-9011-4678-B1EB-A07FD272F0AF']
infos = factory.RegisterClassFactories(clsids)
# commented - from original localserver.serve() method
#pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())
pythoncom.CoResumeClassObjects()
pythoncom.PumpMessages()
factory.RevokeClassFactories( infos )
pythoncom.CoUninitialize()
if __name__=='__main__':
#use this
server_thread = Thread(target=runserver) # Process works as well
server_thread.start()
#instead this
#localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code now works in parallel
Also I have made some improvements like Queue to get data later. I hope it can help others.
add a comment |
up vote
0
down vote
up vote
0
down vote
My problem was solved rewriting the localserver.serve() function and starting it in a new thread as the code below.
import pythoncom
from win32com.client import Dispatch # to get attributes
from win32com.server import register, factory
from threading import Thread
from queue import Queue
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech']
_public_methods_ = ['talktome']
queue_speech = Queue()
def talktome(self,speech):
self.queue_speech.put(speech)
print ('New speech received: ' + speech)
return 'roger'
### ___ ###
# use instead localserver.serve()
def runserver():
# added - multithread support
pythoncom.CoInitialize()
clsids = ['D9C54599-9011-4678-B1EB-A07FD272F0AF']
infos = factory.RegisterClassFactories(clsids)
# commented - from original localserver.serve() method
#pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())
pythoncom.CoResumeClassObjects()
pythoncom.PumpMessages()
factory.RevokeClassFactories( infos )
pythoncom.CoUninitialize()
if __name__=='__main__':
#use this
server_thread = Thread(target=runserver) # Process works as well
server_thread.start()
#instead this
#localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code now works in parallel
Also I have made some improvements like Queue to get data later. I hope it can help others.
My problem was solved rewriting the localserver.serve() function and starting it in a new thread as the code below.
import pythoncom
from win32com.client import Dispatch # to get attributes
from win32com.server import register, factory
from threading import Thread
from queue import Queue
class PythonUtilities(object):
_reg_clsid_ = 'D9C54599-9011-4678-B1EB-A07FD272F0AF'
_reg_desc_ = "Change information between programs"
_reg_progid_ = "Python.LetsTalk"
_public_attrs_ = ['speech']
_public_methods_ = ['talktome']
queue_speech = Queue()
def talktome(self,speech):
self.queue_speech.put(speech)
print ('New speech received: ' + speech)
return 'roger'
### ___ ###
# use instead localserver.serve()
def runserver():
# added - multithread support
pythoncom.CoInitialize()
clsids = ['D9C54599-9011-4678-B1EB-A07FD272F0AF']
infos = factory.RegisterClassFactories(clsids)
# commented - from original localserver.serve() method
#pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())
pythoncom.CoResumeClassObjects()
pythoncom.PumpMessages()
factory.RevokeClassFactories( infos )
pythoncom.CoUninitialize()
if __name__=='__main__':
#use this
server_thread = Thread(target=runserver) # Process works as well
server_thread.start()
#instead this
#localserver.serve(['D9C54599-9011-4678-B1EB-A07FD272F0AF'])
#... rest of the code now works in parallel
Also I have made some improvements like Queue to get data later. I hope it can help others.
answered Nov 14 at 3:54
Eric Trevisani
63
63
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254468%2fkeep-python-com-local-server-listening-open-in-paralallel-while-the-main-code-ru%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You're not supposed to register and serve at the same time as an out-of-process server will be started by pythonw.exe when requested. So first register your server and just do nothing more. See an example here: stackoverflow.com/questions/1054849/…
– Simon Mourier
Nov 12 at 8:53
@SimonMourier, I have already seen this post. Notice that the Rob's answer marked as solved. He explains that ...register.UseCommandLine() only registers a piece of code so much so that it can be accessed even when the server application is closed. Therefore, I need to keep this server running because I need to listen the client. That's why the ...localserver.serve (). And It works. The problem is that when I run the server, everything else waits the server's process ends. Just when I close the server's window manually the code above prints all the client's "speech". It should be real time.
– Eric Trevisani
Nov 12 at 19:12
I understood your question and I pointed to this answer precisely because it explains how to do it. You don't have to run your server and wait for something. You run it manually only for register and unregister. After than, it will be started by pythonw.exe when someone accesses it.
– Simon Mourier
Nov 13 at 8:31
@SimonMourier, yes. You are right. There is no need... register.UseCommandLine() ...localserver.serve() does it. Afterwards, I got a solution rewriting the localserver.serve() function and starting it in a new thread.
– Eric Trevisani
Nov 14 at 3:03