kmisc 2.1.114__py3-none-any.whl → 2.1.115__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kmisc/__init__.py CHANGED
@@ -2735,24 +2735,51 @@ def net_start_single_server(server_port,main_func_name,server_ip='',timeout=0,ma
2735
2735
  return rc
2736
2736
 
2737
2737
  def kmp(mp={},func=None,name=None,timeout=0,quit=False,log_file=None,log_screen=True,log_raw=False, argv=[],queue=None):
2738
+ #Log
2739
+ def LLOG(msg):
2740
+ if 'log' in mp and 'queue' in mp['log']:
2741
+ mp['log']['queue'].put(msg)
2742
+ time.sleep(2)
2743
+
2738
2744
  # Clean
2745
+ def terminate_process(pobj,max_retry=5):
2746
+ for i in range(max_retry):
2747
+ if isinstance(pobj,dict) and 'mp' in pobj:
2748
+ pobj=pobj['mp']
2749
+ if type(pobj).__name__ == 'Process':
2750
+ try:
2751
+ if pobj.is_alive():
2752
+ pobj.terminate()
2753
+ return True
2754
+ except:
2755
+ time.sleep(1)
2756
+ else:
2757
+ break
2758
+ return False
2759
+
2739
2760
  for n in [k for k in mp]:
2740
2761
  if quit is True:
2741
2762
  if n != 'log':
2742
- mp[n]['mp'].terminate()
2743
- if 'log' in mp:
2744
- mp['log']['queue'].put('\nterminate function {}'.format(n))
2763
+ if 'mp' in mp[n] and mp[n]['mp']:
2764
+ LLOG('\nterminate function {}'.format(n))
2765
+ if terminate_process(mp[n]):
2766
+ del mp[n]
2745
2767
  else:
2746
2768
  if mp[n]['timeout'] > 0 and TIME().Int() > mp[n]['timeout']:
2747
- mp[n]['mp'].terminate()
2748
- if 'log' in mp:
2749
- mp['log']['queue'].put('\ntimeout function {}'.format(n))
2750
- if not mp[n]['mp'].is_alive():
2751
- del mp[n]
2769
+ if 'mp' in mp[n]:
2770
+ if terminate_process(mp[n]['mp']):
2771
+ LLOG('\ntimeout function {}'.format(n))
2772
+ del mp[n]['mp']
2752
2773
  if quit is True and 'log' in mp:
2753
- mp['log']['queue'].put('\nterminate function log')
2754
- TIME().Sleep(2)
2755
- mp['log']['mp'].terminate()
2774
+ LLOG('\nterminate function log')
2775
+ if 'mp' in mp['log']:
2776
+ if terminate_process(mp['log']['mp']):
2777
+ del mp['log']['mp']
2778
+ if 'queue' in mp['log']:
2779
+ if terminate_process(mp['log']['queue']):
2780
+ del mp['log']['queue']
2781
+ if 'mp' not in mp['log'] and 'queue' not in mp['log']:
2782
+ del mp['log']
2756
2783
  return
2757
2784
 
2758
2785
  # LOG
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kmisc
3
- Version: 2.1.114
3
+ Version: 2.1.115
4
4
  Summary: Enginering useful library
5
5
  Home-page: https://github.com/kagepark/kmisc
6
6
  Author: Kage Park
@@ -0,0 +1,6 @@
1
+ kmisc/__init__.py,sha256=AQgeY0ISVrpu7EqQ7ubiPoveAiv4Y1bASBD-ZvpTtBM,138839
2
+ kmisc-2.1.115.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
3
+ kmisc-2.1.115.dist-info/METADATA,sha256=FtlMmyiFOT7Is_eHJDNkcOV-quQ-RzOZabgtlkRfEZ0,5523
4
+ kmisc-2.1.115.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
5
+ kmisc-2.1.115.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
6
+ kmisc-2.1.115.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- kmisc/__init__.py,sha256=1b2psgkwI69O6mgGuIq6ftoWsKjWGyWxXxELwza4a5I,137942
2
- kmisc-2.1.114.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
3
- kmisc-2.1.114.dist-info/METADATA,sha256=IAfRdDGTsTSJ5dx1UsMDoxKgs0KgjPpzfhuCTJfbHe8,5523
4
- kmisc-2.1.114.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
5
- kmisc-2.1.114.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
6
- kmisc-2.1.114.dist-info/RECORD,,