Loading openflexure_microscope/captures/capture.py +24 −20 Original line number Diff line number Diff line Loading @@ -131,8 +131,9 @@ class CaptureObject(object): # Stream for buffering capture data self.stream = io.BytesIO() # Event to notify when the stream has finished writing to disk #self.file_ready = Event() self.file_ready = gevent.event.Event() # Access lock for the disk file self.lock = gevent.lock.BoundedSemaphore() # Store a nice ID self.id = uuid.uuid4() #: str: Unique capture ID Loading Loading @@ -161,6 +162,7 @@ class CaptureObject(object): self.stream.write(s) def _stream_to_file(self): with self.lock: logging.info(f"Writing to disk {self.file}") with FileObjectThread(open(self.file, "wb"), 'wb') as outfile: outfile.write(self.stream.getbuffer()) Loading Loading @@ -246,7 +248,7 @@ class CaptureObject(object): self.save_metadata() def save_metadata(self) -> None: gevent.get_hub().threadpool.spawn(self.synchronous_save_metadata) gevent.spawn(self.synchronous_save_metadata) def synchronous_save_metadata(self) -> None: """ Loading @@ -255,6 +257,8 @@ class CaptureObject(object): global EXIF_FORMATS if self.format.upper() in EXIF_FORMATS and self.exists: self.file_ready.wait() with self.lock: logging.debug("Writing exif data to capture file") # Extract current Exif data exif_dict = piexif.load(self.file) Loading Loading
openflexure_microscope/captures/capture.py +24 −20 Original line number Diff line number Diff line Loading @@ -131,8 +131,9 @@ class CaptureObject(object): # Stream for buffering capture data self.stream = io.BytesIO() # Event to notify when the stream has finished writing to disk #self.file_ready = Event() self.file_ready = gevent.event.Event() # Access lock for the disk file self.lock = gevent.lock.BoundedSemaphore() # Store a nice ID self.id = uuid.uuid4() #: str: Unique capture ID Loading Loading @@ -161,6 +162,7 @@ class CaptureObject(object): self.stream.write(s) def _stream_to_file(self): with self.lock: logging.info(f"Writing to disk {self.file}") with FileObjectThread(open(self.file, "wb"), 'wb') as outfile: outfile.write(self.stream.getbuffer()) Loading Loading @@ -246,7 +248,7 @@ class CaptureObject(object): self.save_metadata() def save_metadata(self) -> None: gevent.get_hub().threadpool.spawn(self.synchronous_save_metadata) gevent.spawn(self.synchronous_save_metadata) def synchronous_save_metadata(self) -> None: """ Loading @@ -255,6 +257,8 @@ class CaptureObject(object): global EXIF_FORMATS if self.format.upper() in EXIF_FORMATS and self.exists: self.file_ready.wait() with self.lock: logging.debug("Writing exif data to capture file") # Extract current Exif data exif_dict = piexif.load(self.file) Loading