Comments (7)
Hi Maarten, it sounds like perhaps two things:
- Somehow you're not getting a fresh DB context when creating a new graphic
- Perhaps Django is threaded, and (when reloading quickly) two threads access the same DB context
The solution for both could be the same.
Can you show me how you are calling drawbot-skia from your server app? Replace the actual drawing with a dummy rectangle to keep the example simple.
from drawbot-skia.
Hi Just. Thanks very much for getting back to me. The "not getting a fresh DB context" point you made is all I needed to fix the issue. Days of bouncing around heaps of different ideas and it was as simple as putting importlib.reload(db)
in the top of function to reload the library each time.
import drawbot_skia.drawbot as db
def rect(request):
importlib.reload(db)
db.size(100, 100)
db.fill(0, 1, 0)
db.rect(0, 10, 50, 50)
db.saveImage(f"media/rect.svg")
return HttpResponse("<html><body>Done</body></html>")
Thank you again. Very grateful for your guidance.
from drawbot-skia.
Reload the module may be effective but is not a great solution. I'll try to post a better fix later.
from drawbot-skia.
Actually adding db.newDrawing()
also works. Would that be a better solution?
from drawbot-skia.
Ah yes, newDrawing is a pretty essential thing indeed. Perhaps it's good enough, but try some stress-testing: if this code is indeed run from multiple threads, there will be hard-to-reproduce problems.
from drawbot-skia.
The following example should be thread-safe:
from drawbot_skia.drawing import Drawing
# from drawbot_skia.path import BezierPath
# from math import *
# from random import randint, random
db = Drawing()
db.rect(10, 10, 200, 300)
db.saveImage("maarten_test.png")
I added some comments to show where you'd find names that are normally part of the "drawbot" namespace, but aren't part of the Drawing
class.
from drawbot-skia.
This is great Just. Thank you very much for the hand up.
from drawbot-skia.
Related Issues (17)
- fontVariations() does not work correctly on Linux HOT 3
- Initial Update
- The subset of Drawbot that is currently supported
- Need fallback for conic to cubic conversion HOT 7
- listFontVariations missing HOT 4
- newPage() requires arguments HOT 4
- drawBot compatibility test HOT 1
- Dependency issues HOT 3
- Error while import drawbot_skia HOT 9
- Some PDF test fail on macos-latest (Big Sur)
- integration in jupyter notebook? HOT 3
- blendMode SVG looks wrong HOT 4
- functions not possible? HOT 4
- tracking supported? HOT 2
- Skia ShapedText HOT 2
- CPAL/COLR/COLRv1: need api to choose palette
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drawbot-skia.