diff --git a/openslides/utils/autoupdate.py b/openslides/utils/autoupdate.py index 3bb64a2d7..5cddda1f4 100644 --- a/openslides/utils/autoupdate.py +++ b/openslides/utils/autoupdate.py @@ -5,6 +5,7 @@ from asgiref.inmemory import ChannelLayer from channels import Channel, Group from channels.auth import channel_session_user, channel_session_user_from_http from django.apps import apps +from django.db import transaction from django.utils import timezone from ..users.auth import AnonymousUser @@ -108,14 +109,19 @@ def inform_changed_data(instance, is_deleted=False): # Instance has no method get_root_rest_element. Just ignore it. pass else: - try: - Channel('autoupdate.send_data').send({ - 'collection_string': root_instance.get_collection_string(), - 'pk': root_instance.pk, - 'is_deleted': is_deleted and instance == root_instance, - 'dispatch_uid': root_instance.get_access_permissions().get_dispatch_uid()}) - except ChannelLayer.ChannelFull: - pass + # If currently there is an open database transaction, then the following + # function is only called, when the transaction is commited. If there + # is currently no transaction, then the function is called immediately. + def send_autoupdate(): + try: + Channel('autoupdate.send_data').send({ + 'collection_string': root_instance.get_collection_string(), + 'pk': root_instance.pk, + 'is_deleted': is_deleted and instance == root_instance, + 'dispatch_uid': root_instance.get_access_permissions().get_dispatch_uid()}) + except ChannelLayer.ChannelFull: + pass + transaction.on_commit(send_autoupdate) def inform_changed_data_receiver(sender, instance, **kwargs): diff --git a/requirements_production.txt b/requirements_production.txt index b4b3a6107..adb203614 100644 --- a/requirements_production.txt +++ b/requirements_production.txt @@ -1,5 +1,5 @@ # Requirements for OpenSlides in production in alphabetical order -Django>=1.8,<1.11,!=1.10.0 +Django>=1.9,<1.11,!=1.10.0 beautifulsoup4>=4.5,<4.6 channels>=0.15,<1.0 djangorestframework>=3.2.0,<3.5