open files by drag&drop
This commit is contained in:
49
scribble.py
49
scribble.py
@@ -1,44 +1,9 @@
|
||||
import os
|
||||
import urllib
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import multiprocessing
|
||||
import time
|
||||
|
||||
from multiprocessing import Pool
|
||||
|
||||
file = "/tmp/tmp123123"
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from time import sleep
|
||||
|
||||
def writer():
|
||||
with open(file, "w+b") as f:
|
||||
for i in range(0, 10):
|
||||
f.write(("%s"%(i)).encode("utf8"))
|
||||
time.sleep(0.5)
|
||||
print("writing ", time.time())
|
||||
|
||||
def reader():
|
||||
with open(file, "rb") as f:
|
||||
for i in range(0,10):
|
||||
|
||||
lines = f.readlines()
|
||||
time.sleep(0.5)
|
||||
print("read ", time.time())
|
||||
|
||||
pool = Pool(5)
|
||||
|
||||
with pool as p:
|
||||
p.apply_async(writer)
|
||||
p.apply_async(reader)
|
||||
|
||||
pool.join()
|
||||
|
||||
|
||||
executor = ThreadPoolExecutor(2)
|
||||
future1 = executor.submit(writer)
|
||||
future2 = executor.submit(reader)
|
||||
|
||||
print(future1.result())
|
||||
print(future2.result())
|
||||
|
||||
|
||||
url = "file:///home/andi/.local/share/ravenlog/session.ini"
|
||||
|
||||
p = urlparse(url)
|
||||
final_path = os.path.abspath(os.path.join(p.netloc, p.path))
|
||||
print(final_path)
|
||||
|
||||
Reference in New Issue
Block a user