Skip to content

Commit

Permalink
exeのマルチプロセス対応
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroki Fujii committed Sep 11, 2020
1 parent 982b10e commit d3a2c87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dist/
*.exp
*.lib
*.spec
*.pyo
pl_auto_save
/test.mp3
/test.py
Expand Down
16 changes: 11 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import win32api
import winerror
import datetime
import multiprocessing
import globalVars
import m3uManager
import data_dict
Expand All @@ -33,14 +34,18 @@ class Main(AppBase.MainBase):
def __init__(self):
super().__init__()
self.mutex = 0
multiprocessing.freeze_support() #これがないとマルチプロセスでおかしなことになる


def initialize(self):
# 多重起動処理8
self.mutex = win32event.CreateMutex(None, 1, constants.PIPE_NAME)
try: self.mutex = win32event.CreateMutex(None, 1, constants.PIPE_NAME)
except: pass
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
lampPipe.sendPipe()
try: lampPipe.sendPipe()
except: pass
self.mutex = 0
exit()
sys.exit()
else:
lampPipe.startPipeServer()

Expand Down Expand Up @@ -76,5 +81,6 @@ def SetGlobalVars(self):

def __del__(self):
if self.mutex != 0:
win32event.ReleaseMutex(self.mutex)
self.mutex = 0
try: win32event.ReleaseMutex(self.mutex)
except: pass
self.mutex = 0
4 changes: 3 additions & 1 deletion tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def runcmd(cmd):
shutil.rmtree("dist\\")

print("Building...")
runcmd("pyinstaller --debug all application.py") #--windowed --log-level=ERROR
runcmd("pyinstaller --windowed --log-level=ERROR application.py")
if len(sys.argv) > 1 and sys.argv[1] == "-d":
runcmd("pyinstaller application.py")
shutil.copytree("locale\\","dist\\application\\locale", ignore=shutil.ignore_patterns("*.po", "*.pot", "*.po~"))
print("Done!")

0 comments on commit d3a2c87

Please sign in to comment.