Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 9992d73

Browse files
authored
WIP Bound request queue (#28)
Bound request queue
1 parent 401b977 commit 9992d73

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [0.11.1] - 2017-10-19
6+
### Fixed
7+
- :snail: :racehorse: Fixed a performance issue. In 0.11.0 we introduced an internal request queue to fix some bugs. This request queue was boundless and in certain cases it could become really large and slow down the app. Now, we remove old requests from this queue when they are no longer needed, keeping its size under control. Originally reported in https://github.com/plotly/dash-renderer/issues/27
8+
59
## [0.11.0] - 2017-09-28
610
### Fixed
711
- 🐞 Previously, old requests could override new requests if their response was longer than the new one.

Diff for: dash_renderer/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# command in the dash_html_components package which printed out:
88
# `dash_html_components.__init__: module references __file__`
99
# TODO - Understand this better
10-
from .version import __version__
10+
# from .version import __version__
11+
__version__ = '0.11.1'
1112
__file__
1213

1314
# Dash renderer's dependencies get loaded in a special order by the server:

Diff for: dash_renderer/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.11.0'
1+
__version__ = '0.11.1'

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-renderer",
3-
"version": "0.11.0",
3+
"version": "0.11.1",
44
"description": "render dash components in react",
55
"main": "src/index.js",
66
"scripts": {

Diff for: src/actions/index.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ export function notifyObservers(payload) {
397397
const updateRequestQueue = rejected => {
398398
const postRequestQueue = getState().requestQueue
399399
const thisRequestIndex = getThisRequestIndex();
400+
if (thisRequestIndex === -1) {
401+
// It was already pruned away
402+
return;
403+
}
400404
const updatedQueue = adjust(
401405
merge(__, {
402406
status: res.status,
@@ -406,15 +410,32 @@ export function notifyObservers(payload) {
406410
thisRequestIndex,
407411
postRequestQueue
408412
);
413+
// We don't need to store any requests before this one
414+
const thisControllerId = postRequestQueue[
415+
thisRequestIndex].controllerId;
416+
const prunedQueue = updatedQueue.filter(
417+
(queueItem, index) => {
418+
return (
419+
queueItem.controllerId !== thisControllerId ||
420+
index >= thisRequestIndex
421+
);
422+
}
423+
);
409424

410-
dispatch(setRequestQueue(updatedQueue));
425+
dispatch(setRequestQueue(prunedQueue));
411426
}
412427

413428
const isRejected = () => {
414429
const latestRequestIndex = findLastIndex(
415430
propEq('controllerId', newRequestQueue[i].controllerId),
416431
getState().requestQueue
417432
);
433+
/*
434+
* Note that if the latest request is still `loading`
435+
* or even if the latest request failed,
436+
* we still reject this response in favor of waiting
437+
* for the latest request to finish.
438+
*/
418439
const rejected = latestRequestIndex > getThisRequestIndex();
419440
return rejected;
420441
}

Diff for: tests/test_render.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ def update_output(value):
462462
)
463463

464464
self.request_queue_assertions(
465-
expected_length=call_count.value, check_rejected=False)
465+
expected_length=1,
466+
check_rejected=False)
466467

467468
assert_clean_console(self)
468469

@@ -1535,5 +1536,4 @@ def update_output(n_clicks):
15351536
'return window.store.getState().requestQueue'
15361537
)
15371538
self.assertFalse(request_queue[0]['rejected'])
1538-
self.assertTrue(request_queue[1]['rejected'])
1539-
self.assertFalse(request_queue[2]['rejected'])
1539+
self.assertEqual(len(request_queue), 1)

0 commit comments

Comments
 (0)