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 return result
def input_process(self, stdin_fd, sq, str): def input_process(self, stdin_fd, sq, str):
import sys from core import osex
if sys.platform != 'win32': osex.linux_ignore_UserWarning()
# 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)
sys.stdin = os.fdopen(stdin_fd) sys.stdin = os.fdopen(stdin_fd)
try: try:
@ -386,19 +381,15 @@ class InteractBase(object):
if time.time() - t > max_time_sec: if time.time() - t > max_time_sec:
break break
p.terminate() p.terminate()
sq.close()
old_stdin = sys.stdin old_stdin = sys.stdin
sys.stdin = os.fdopen( os.dup(sys.stdin.fileno()) ) sys.stdin = os.fdopen( os.dup(sys.stdin.fileno()) )
old_stdin.close() old_stdin.close()
return inp return inp
def input_process_skip_pending(self, stdin_fd): def input_process_skip_pending(self, stdin_fd):
import sys from core import osex
if sys.platform != 'win32': osex.linux_ignore_UserWarning()
# 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)
sys.stdin = os.fdopen(stdin_fd) sys.stdin = os.fdopen(stdin_fd)
while True: 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 progress_bar_inc(self, c): self.c2s.put ( {'op': 'progress_bar_inc' , 'c':c } )
def _subprocess_run(self, client_dict, s2c, c2s): def _subprocess_run(self, client_dict, s2c, c2s):
import sys from core import osex
if sys.platform != 'win32': osex.linux_ignore_UserWarning()
# 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)
self.s2c = s2c
self.c2s = c2s self.c2s = c2s
data = None data = None
is_error = False
try: try:
self.on_initialize(client_dict) self.on_initialize(client_dict)
@ -86,16 +81,18 @@ class Subprocessor(object):
self.on_finalize() self.on_finalize()
c2s.put ( {'op': 'finalized'} ) c2s.put ( {'op': 'finalized'} )
return
except Subprocessor.SilenceException as e: except Subprocessor.SilenceException as e:
pass c2s.put ( {'op': 'error', 'data' : data} )
except Exception as e: except Exception as e:
c2s.put ( {'op': 'error', 'data' : data} )
if data is not None: if data is not None:
print ('Exception while process data [%s]: %s' % (self.get_data_name(data), traceback.format_exc()) ) print ('Exception while process data [%s]: %s' % (self.get_data_name(data), traceback.format_exc()) )
else: else:
print ('Exception: %s' % (traceback.format_exc()) ) print ('Exception: %s' % (traceback.format_exc()) )
c2s.put ( {'op': 'error', 'data' : data} ) c2s.close()
s2c.close()
self.c2s = None
# disable pickling # disable pickling
def __getstate__(self): def __getstate__(self):

View file

@ -34,3 +34,11 @@ def get_screen_size():
pass pass
return (1366, 768) 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(): def get_default_ttf_font_name():
platform = sys.platform 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') elif platform == 'darwin': return darwin_font_name_map.get(system_language, 'cour')
else: return linux_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 import multiprocessing
multiprocessing.set_start_method("spawn") multiprocessing.set_start_method("spawn")
import sys from core import osex
if sys.platform != 'win32': osex.linux_ignore_UserWarning()
# 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.leras import nn from core.leras import nn
nn.initialize_main_env() nn.initialize_main_env()
@ -20,7 +15,6 @@ if __name__ == "__main__":
import argparse import argparse
from core import pathex from core import pathex
from core import osex
from pathlib import Path from pathlib import Path
from core.interact import interact as io from core.interact import interact as io