kmisc 2.1.113__tar.gz → 2.1.115__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kmisc
3
- Version: 2.1.113
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
@@ -2076,9 +2076,11 @@ def findPlanCfg(filename,find_name=None,default=False,original=False,date=None):
2076
2076
  data=cat(filename)
2077
2077
  if data is False:
2078
2078
  return default
2079
- if find_name and isinstance(find_name,str):
2079
+ if find_name:
2080
+ if isinstance(find_name,str):
2081
+ find_name=find_name.split(',')
2080
2082
  out=[]
2081
- for ff in find_name.split(','):
2083
+ for ff in find_name:
2082
2084
  found=False
2083
2085
  for i in data.split('\n'):
2084
2086
  if isinstance(i,str) and '=' in i:
@@ -2733,24 +2735,51 @@ def net_start_single_server(server_port,main_func_name,server_ip='',timeout=0,ma
2733
2735
  return rc
2734
2736
 
2735
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
+
2736
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
+
2737
2760
  for n in [k for k in mp]:
2738
2761
  if quit is True:
2739
2762
  if n != 'log':
2740
- mp[n]['mp'].terminate()
2741
- if 'log' in mp:
2742
- 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]
2743
2767
  else:
2744
2768
  if mp[n]['timeout'] > 0 and TIME().Int() > mp[n]['timeout']:
2745
- mp[n]['mp'].terminate()
2746
- if 'log' in mp:
2747
- mp['log']['queue'].put('\ntimeout function {}'.format(n))
2748
- if not mp[n]['mp'].is_alive():
2749
- 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']
2750
2773
  if quit is True and 'log' in mp:
2751
- mp['log']['queue'].put('\nterminate function log')
2752
- TIME().Sleep(2)
2753
- 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']
2754
2783
  return
2755
2784
 
2756
2785
  # LOG
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kmisc
3
- Version: 2.1.113
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
File without changes
File without changes
File without changes
File without changes
File without changes