문제

I have a web server built with Django. I need to update some information in the same database used by Django specifically through a UDP connection.

What is the best approach to implement this?

도움이 되었습니까?

해결책

First of all, use twisted to build a server to listen to UDP

Secondly: If you have unique constraints you WILL run into database deadlock issues if there are multiple UDP clients so want to use some form of serialization for your DB writes - assuming your database transactions are somewhat atomic. Celery will probably do that for you, but remember to run the worker with --concurrency=1. Especially if your Django views do more than one .save() on a model instance.

다른 팁

Build a separate socket server. In order to use the project's database and settings do: export PYTHONPATH='path/to/your/project' <-- it gives the ability to import from other project modules export DJANGO_SETTINGS_MODULE='projectname.settings' <-- use project database and settings

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top