0

I am using pygame and want to communicate with server. So I decided to create a main screen button that will run the server file, so others can join a local hosted game. However when I try to use import server,exec("server.py") or os.system("python server.py") the file stops every time to run the other file.

How can I then run a file without it stopping?

@Artyer wrote the answer in the comments, to solve this you need to do os.popen("python server.py")

Sadru
  • 46
  • 1
  • 9
  • 1
    Do you want to start a new thread of a new subprocess to run it in? – Artyer Feb 10 '20 at 15:51
  • @Artyer I am kinda new to programming so I don't know what you mean, but I guess it would be a different subprocess, it shouldn't have anything in common with the file that runs it. So like no variables or functions are passed down. – Sadru Feb 10 '20 at 15:55
  • In that case, does this answer your question: https://stackoverflow.com/questions/636561/how-can-i-run-an-external-command-asynchronously-from-python – Artyer Feb 10 '20 at 15:56
  • 2
    Flagging as dupe then: [How can I run an external command asynchronously from Python?](https://stackoverflow.com/questions/636561/how-can-i-run-an-external-command-asynchronously-from-python) – Artyer Feb 10 '20 at 16:10

0 Answers0