run_daemon 고도화. 1분에 4번 부름
This commit is contained in:
+22
-6
@@ -1,9 +1,17 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
import glob
|
import glob
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import concurrent.futures
|
||||||
|
|
||||||
|
def run(webPath):
|
||||||
|
print(webPath)
|
||||||
|
obj = urllib.request.urlopen(webPath)
|
||||||
|
obj.read()
|
||||||
|
|
||||||
|
def main():
|
||||||
basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
hiddenList = []
|
hiddenList = []
|
||||||
|
|
||||||
@@ -18,18 +26,26 @@ for line in open(basepath+'/d_shared/common_path.js'):
|
|||||||
webBase = webBase.strip(' \'",')
|
webBase = webBase.strip(' \'",')
|
||||||
break
|
break
|
||||||
|
|
||||||
|
servList = []
|
||||||
for path in glob.glob(basepath+'/*/d_setting/DB.php'):
|
for path in glob.glob(basepath+'/*/d_setting/DB.php'):
|
||||||
servPath = os.path.dirname(os.path.dirname(path))
|
servPath = os.path.dirname(os.path.dirname(path))
|
||||||
if servPath in hiddenList:
|
if servPath in hiddenList:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
servRelPath = os.path.relpath(servPath, basepath)
|
servRelPath = os.path.relpath(servPath, basepath)
|
||||||
|
|
||||||
webPath = webBase + '/' + servRelPath + '/proc.php'
|
webPath = webBase + '/' + servRelPath + '/proc.php'
|
||||||
print(webPath)
|
servList.append(webPath)
|
||||||
|
|
||||||
|
with concurrent.futures.ThreadPoolExecutor(max_workers=len(servList)) as executor:
|
||||||
|
waiters=[]
|
||||||
|
for _ in range(4):
|
||||||
|
for webPath in servList:
|
||||||
|
future = executor.submit(run, webPath)
|
||||||
|
waiters.append(future)
|
||||||
|
time.sleep(15)
|
||||||
|
for future in waiters:
|
||||||
|
future.done()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# execute only if run as a script
|
||||||
obj = urllib.request.urlopen(webPath)
|
main()
|
||||||
res = obj.read()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user