Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/stash.py

Issue 2448913002: wptserve: Import the latest revision of wptserve-related files. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/server.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/stash.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/stash.py b/third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/stash.py
index b546191932240007fdd3bdba927caa0cfb18912a..b6bd6eed442a2c1e22c8cfb6d294fa810991a3de 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/stash.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/stash.py
@@ -2,7 +2,6 @@ import base64
import json
import os
import uuid
-from multiprocessing import Process
from multiprocessing.managers import BaseManager, DictProxy
class ServerDictManager(BaseManager):
@@ -57,18 +56,19 @@ def start_server(address=None, authkey=None):
#TODO: Consider expiring values after some fixed time for long-running
#servers
-# TODO(kristijanburnik): Provide shared Stash support for WebSockets.
-
class Stash(object):
- """Key-value store for persisting data across HTTP/S requests.
+ """Key-value store for persisting data across HTTP/S and WS/S requests.
- This data store is specifically designed for persisting data across
- HTTP and HTTPS requests. The synchronization model is usually done by using
- the SyncManager from the multiprocessing module.
+ This data store is specifically designed for persisting data across server
+ requests. The synchronization is achieved by using the BaseManager from
+ the multiprocessing module so different processes can acccess the same data.
- Stash can be used interchangeably between HTTP and HTTPS requests as both
- processes are accessing the same resource (e.g. a Manager.dict).
- The WS and WSS servers are currently not supported.
+ Stash can be used interchangeably between HTTP, HTTPS, WS and WSS servers.
+ A thing to note about WS/S servers is that they require additional steps in
+ the handlers for accessing the same underlying shared data in the Stash.
+ This can usually be achieved by using load_env_config(). When using Stash
+ interchangeably between HTTP/S and WS/S request, the path part of the key
+ should be expliclitly specified if accessing the same key/value subset.
The store has several unusual properties. Keys are of the form (path,
uuid), where path is, by default, the path in the HTTP request and
@@ -118,7 +118,7 @@ class Stash(object):
if internal_key in self.data:
raise StashError("Tried to overwrite existing shared stash value "
"for key %s (old value was %s, new value is %s)" %
- (internal_key, self[str(internal_key)], value))
+ (internal_key, self.data[str(internal_key)], value))
else:
self.data[internal_key] = value
@@ -130,7 +130,7 @@ class Stash(object):
the current request path)"""
internal_key = self._wrap_key(key, path)
value = self.data.get(internal_key, None)
- if not value is None:
+ if value is not None:
try:
self.data.pop(internal_key)
except KeyError:
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/tools/wptserve/wptserve/server.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698