Hello everyone
i want to use multiprocess module and i want to write one json file but did not work good.
i tried to run one process only that work well but run with other process raise excception json decode error.
code:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
import time
from multiprocessing import Process
import json
def fun1():
while True:
with open(“ram.json”,“r”) as wrx:
alr=
alr=json.load(wrx)
with open("ram.json","w") as wrx:
al={}
al["fun1"]="bunufun1 yazdı..."
alr.append(al)
json.dump(alr,wrx)
def fun2():
while True:
with open("ram.json", "r") as wrx:
alr = []
alr = json.load(wrx)
with open("ram.json", "w") as wrx:
al = {}
al["fun2"] = "bunufun2 yazdı..."
alr.append(al)
json.dump(alr, wrx)
def fun3():
while True:
with open(“ram.json”, “r”) as wrx:
alr =
alr = json.load(wrx)
with open("ram.json", "w") as wrx:
al = {}
al["fun3"] = "bunufun3 yazdı..."
alr.append(al)
json.dump(alr, wrx)
def fun4():
while True:
with open(“ram.json”, “r”) as wrx:
alr =
alr = json.load(wrx)
with open("ram.json", "w") as wrx:
al = {}
al["fun4"] = "bunufun4 yazdı..."
alr.append(al)
json.dump(alr, wrx)
def fun5():
while True:
with open(“ram.json”,“r”) as wrx:
al=
al=json.load(wrx)
print(al)
def main():
p1 = Process(target=fun1)
p2 = Process(target=fun2)
p3 = Process(target=fun3)
p4 = Process(target=fun4)
p5 = Process(target=fun5)
p1.start()
p2.start()
p3.start()
p4.start()
if name == “main”:
main()
code::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)