I'm working on a Django project that uses a flatbed scanner. It takes a long time to connect to the scanner. So I'm looking for a way to re-use the scanner instance.
Serialization seems to be the go to solution for this problem. Unfortunately I can not serialize or pickle the scanner instance. I keep running into errors that tell me that that serialization failed.
Is there an alternative way to re-use the same scanner instance for multiple scans? A back-end trick or maybe some front-end magic? (Note, I know nothing about front-end development.)
We can cheat a little!
The project will be running offline on a local computer, there is no internet or network connection at all. This might give options that are otherwise insecure.
Stuff I'm using for scanning
- sane, packages for accessing scanners
- python3-sane, a Python wrapper for sane
- Image Scan, drivers for scanners
After looking around for a bit I found RPyC. The tutorial provides a working example, I got it running in a couple of minutes.
The service starts and connects to the scanner. Multiple clients can call the service and scan immediately.