I am implementing a progress monitoring function using Django. However, I
cannot get the updated value in the front end.
A Django management command is executed by popen to keep updating the
progress of the model webscan. Scan is a Django model and progress_info is
an attribute of the model which is saved in database. The code is as
follows:
d = 10
while (d) :
time.sleep(10)
try:
isBusy = server.call("framework.busy?")
logging.debug(isBusy)
if isBusy.strip() == 'true':
progress = webscan.progress
webscan.progress_info = progress
webscan.save()
logging.debug("%s"%progress)
else:
d = 0
except Exception as e:
logging.debug("In an exception when calling busy.
Exception: %s and Type %s"%(e, type(e)))
d -= 1
In the front-end, I make an ajax call to get the value of progress_info.
The handler simply get the value of webscan.progress_infoand returns it to
the front-end. The code is as follows:
@property
def get_progress(self):
return self.progress_info
Using the GUI of the DB, I can see that the value of progress_info is kept
updated. However, the ajax call keeps returning 0 to the front-end until
the command finishes (0 is the initial value ofprogress_info).
I guess it is because of the locking mechanism of DB or Django but do not
fully understand why. Could anyone help me with it? Thanks a lot~
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/HJLl20zLsSMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.