Retrait verrou camera et threading : revert approche simple sans deadlock
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import io
|
||||
import logging
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
@@ -67,7 +66,6 @@ class Camera:
|
||||
self.webcam = None
|
||||
self.webcam_index = -1
|
||||
self.preview_dslr_ok = True # True si le dernier preview DSLR a reussi
|
||||
self._lock = threading.Lock() # Verrou pour eviter acces gphoto2 concurrent
|
||||
|
||||
def connecter(self, source=None) -> bool:
|
||||
"""Connecte la camera. source: 'gphoto2', 'webcam:0', 'webcam:2', etc."""
|
||||
@@ -147,7 +145,6 @@ class Camera:
|
||||
def _capture_gphoto2(self, chemin_dest: Path) -> Path | None:
|
||||
from PIL import Image as PILImage
|
||||
|
||||
with self._lock:
|
||||
for attempt in range(3):
|
||||
try:
|
||||
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
||||
@@ -201,10 +198,9 @@ class Camera:
|
||||
return None # Pas de simulation ni webcam en dehors du mode dedie
|
||||
|
||||
def activer_viewfinder(self):
|
||||
"""Active le LiveView sur les Canon (nécessaire avant capture_preview)."""
|
||||
"""Active le LiveView sur les Canon."""
|
||||
if self.mode != "gphoto2" or not self.connectee:
|
||||
return
|
||||
with self._lock:
|
||||
try:
|
||||
cfg = self.camera.get_config()
|
||||
vf = cfg.get_child_by_name("viewfinder")
|
||||
@@ -218,7 +214,6 @@ class Camera:
|
||||
"""Désactive le LiveView."""
|
||||
if self.mode != "gphoto2" or not self.connectee:
|
||||
return
|
||||
with self._lock:
|
||||
try:
|
||||
cfg = self.camera.get_config()
|
||||
vf = cfg.get_child_by_name("viewfinder")
|
||||
@@ -229,7 +224,6 @@ class Camera:
|
||||
log.warning(f"Viewfinder non supporté : {e}")
|
||||
|
||||
def _preview_gphoto2(self) -> bytes | None:
|
||||
with self._lock:
|
||||
try:
|
||||
fichier = self.camera.capture_preview()
|
||||
donnees = bytes(fichier.get_data_and_size())
|
||||
|
||||
Reference in New Issue
Block a user