Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AsyncJsonDescriptionReader:
- file = None
- locker = None
- def read(self):
- AsyncJsonDescriptionReader.locker.acquire()
- string = AsyncJsonDescriptionReader.file.readline()
- AsyncJsonDescriptionReader.locker.release()
- if len(string) > 0:
- return self.transformer.transform(json.loads(string))
- else:
- return None
- def __init__(self, description_path, ind):
- self.ind = ind
- if AsyncJsonDescriptionReader.locker is None:
- AsyncJsonDescriptionReader.locker = Lock()
- if AsyncJsonDescriptionReader.file is None:
- AsyncJsonDescriptionReader.file = open(description_path, 'r')
- print(id(AsyncJsonDescriptionReader.locker), id(AsyncJsonDescriptionReader.file))
- self.transformer = JSON2ClassTransformer()
Add Comment
Please, Sign In to add comment