fix for linux

This commit is contained in:
Colombo 2020-02-29 14:49:46 +04:00
parent dbf28eeebf
commit 7f609d0f0a
5 changed files with 31 additions and 41 deletions

View file

@ -357,13 +357,8 @@ class InteractBase(object):
return result
def input_process(self, stdin_fd, sq, str):
import sys
if sys.platform != 'win32':
# fix for Linux , Ignoring :
# /usr/lib/python3.6/multiprocessing/semaphore_tracker.py:143:
# UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown
import warnings
warnings.simplefilter(action='ignore', category=UserWarning)
from core import osex
osex.linux_ignore_UserWarning()
sys.stdin = os.fdopen(stdin_fd)
try:
@ -386,19 +381,15 @@ class InteractBase(object):
if time.time() - t > max_time_sec:
break
p.terminate()
sq.close()
old_stdin = sys.stdin
sys.stdin = os.fdopen( os.dup(sys.stdin.fileno()) )
old_stdin.close()
return inp
def input_process_skip_pending(self, stdin_fd):
import sys
if sys.platform != 'win32':
# fix for Linux , Ignoring :
# /usr/lib/python3.6/multiprocessing/semaphore_tracker.py:143:
# UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown
import warnings
warnings.simplefilter(action='ignore', category=UserWarning)
from core import osex
osex.linux_ignore_UserWarning()
sys.stdin = os.fdopen(stdin_fd)
while True:

View file

@ -55,17 +55,12 @@ class Subprocessor(object):
def progress_bar_inc(self, c): self.c2s.put ( {'op': 'progress_bar_inc' , 'c':c } )
def _subprocess_run(self, client_dict, s2c, c2s):
import sys
if sys.platform != 'win32':
# fix for Linux , Ignoring :
# /usr/lib/python3.6/multiprocessing/semaphore_tracker.py:143:
# UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown
import warnings
warnings.simplefilter(action='ignore', category=UserWarning)
from core import osex
osex.linux_ignore_UserWarning()
self.s2c = s2c
self.c2s = c2s
data = None
is_error = False
try:
self.on_initialize(client_dict)
@ -86,16 +81,18 @@ class Subprocessor(object):
self.on_finalize()
c2s.put ( {'op': 'finalized'} )
return
except Subprocessor.SilenceException as e:
pass
c2s.put ( {'op': 'error', 'data' : data} )
except Exception as e:
c2s.put ( {'op': 'error', 'data' : data} )
if data is not None:
print ('Exception while process data [%s]: %s' % (self.get_data_name(data), traceback.format_exc()) )
else:
print ('Exception: %s' % (traceback.format_exc()) )
c2s.put ( {'op': 'error', 'data' : data} )
c2s.close()
s2c.close()
self.c2s = None
# disable pickling
def __getstate__(self):

View file

@ -34,3 +34,11 @@ def get_screen_size():
pass
return (1366, 768)
def linux_ignore_UserWarning():
if sys.platform[0:3] != 'win':
# fix for Linux , Ignoring :
# /usr/lib/python3.6/multiprocessing/semaphore_tracker.py:143:
# UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown
import warnings
warnings.simplefilter(action='ignore', category=UserWarning)

View file

@ -25,6 +25,6 @@ linux_font_name_map = {
def get_default_ttf_font_name():
platform = sys.platform
if platform == 'win32': return windows_font_name_map.get(system_language, 'cour')
if platform[0:3] == 'win': return windows_font_name_map.get(system_language, 'cour')
elif platform == 'darwin': return darwin_font_name_map.get(system_language, 'cour')
else: return linux_font_name_map.get(system_language, 'cour')

10
main.py
View file

@ -3,13 +3,8 @@ if __name__ == "__main__":
import multiprocessing
multiprocessing.set_start_method("spawn")
import sys
if sys.platform != 'win32':
# fix for Linux , Ignoring :
# /usr/lib/python3.6/multiprocessing/semaphore_tracker.py:143:
# UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown
import warnings
warnings.simplefilter(action='ignore', category=UserWarning)
from core import osex
osex.linux_ignore_UserWarning()
from core.leras import nn
nn.initialize_main_env()
@ -20,7 +15,6 @@ if __name__ == "__main__":
import argparse
from core import pathex
from core import osex
from pathlib import Path
from core.interact import interact as io