Questions tagged [shared-state]

28 questions
22
votes
2 answers

How to share a string amongst multiple processes using Managers() in Python?

I need to read strings written by multiprocessing.Process instances from the main process. I already use Managers and queues to pass arguments to processes, so using the Managers seems obvious, but Managers do not support strings: A manager…
Bengt
  • 14,011
  • 7
  • 48
  • 66
14
votes
2 answers

How can I provide shared state to my Flask app with multiple workers without depending on additional software?

I want to provide shared state for a Flask app which runs with multiple workers, i. e. multiple processes. To quote this answer from a similar question on this topic: You can't use global variables to hold this sort of data. [...] Use a data source…
finefoot
  • 9,914
  • 7
  • 59
  • 102
11
votes
2 answers

Sharing static members between template instantiations? (impossible?)

I am doing something that is probably silly, but it would be nice if it worked. I am attempting to specialize types in a way that I need my own lookup structure that is essentially global (but ideally encapsulated as a class variable), but I want…
6
votes
1 answer

Using Python's multiprocessing.pool.map to manipulate the same integer

Problem I'm using Python's multiprocessing module to execute functions asynchronously. What I want to do is be able to track the overall progress of my script as each process calls and executes def add_print. For instance, I would like the code…
Austin A
  • 2,990
  • 6
  • 27
  • 42
3
votes
1 answer

shared mutable state: when to use IORefs

I have a main thread that writes to a Map and a PSQ. In both the Map and the PSQ I use the same keys so that by looking at the PSQ the entry with min priority can be found with O(1) complexity and be mapped to a value in the Map. Now, whilst my main…
J Fritsch
  • 3,338
  • 1
  • 18
  • 40
3
votes
4 answers

Two threads using a same variable

I have two threads: 'main' and 'worker', and one global variable bool isQuitRequested that will be used by the main thread to inform worker, when it's time to quit its while loop (something like this: while(isQuitRequested == false) { ... do some…
Gediminas
  • 1,830
  • 3
  • 27
  • 47
3
votes
1 answer

How do I avoid global state when using custom constructors in ruamel.yaml?

I am using ruamel.yaml to parse a complex YAML document where certain tagged nodes require special treatment. I inject my custom parsing logic using add_multi_constructor, as recommended by the published examples. The problem is that I need to…
Pavel Kirienko
  • 1,162
  • 1
  • 15
  • 31
3
votes
3 answers

How to change shared state in Alpine.js?

I'm trying to hide multiple elements inside the DOM by changing shared state when window is resized.
3
votes
1 answer

Has the `message-passing/shared-state' dilemma (concurrency & distribution) taken form of a `Holywar'?

I'm not too well-informed about the state of the discussion about which model is better, so I would like to ask a pretty straight question: Does it look like two opposing views having really heatened dispute? E.g. like prototype/class based OOP or…
Bubba88
  • 1,910
  • 20
  • 44
3
votes
5 answers

What shared state distributed systems exist which can handle objects in the native language?

As far as I know there is Terracotta and Maglev. Are there any others?
yazz.com
  • 57,320
  • 66
  • 234
  • 385
2
votes
1 answer

How to share IORef state between two function invocations in Haskell when using IO?

I'm trying to learn Haskell and I'm playing around with IORef to which I try to save and find records. My code looks something like this (note that I've chosen "String" as IORef type in this example only for convienence and briefty, in my actual…
Johan
  • 37,479
  • 32
  • 149
  • 237
2
votes
1 answer

Design patterns for shared state with many to many streaming

I'm writing an online whiteboard application for fun, where multiple users view the same whiteboard and can draw on it. I'm using websockets (vanilla JS on the frontend, Scala on the backend), and right now am essentially just broadcasting mouse…
Nathan
  • 73,987
  • 14
  • 40
  • 69
2
votes
1 answer

Is there a relationship between CRDTs and the RAFT protocol - or are they orthogonal?

Take the use case of a multi-player networked game. Instantly you have the problem of replicating and reconciling shared state across the network. There appear to be a multiple of tools aimed at aspect of this problem, and two in particular seem to…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
1
vote
2 answers

getServerSideProps in _app.tsx in Next.js

So, here's the situation. I'm trying to get a "language" cookie in the app initialization to change the UI accordingly. For example, if the language is "Arabic" (ar), I revert the layout to be "RTL", and vise versa. There are two ways to achieve…
Ruby
  • 2,207
  • 12
  • 42
  • 71
1
vote
1 answer

Is it practical to mount a block storage to multiple VPS running Docker Swarm for shared storage?

Looking at multiple options to implement a shared storage for a Docker Swarm, I can see most of them require a special Docker plugin: sshFs CephFS glusterFS S3 and others ... but one thing that is not mentioned anywhere is just mounting a typical…
Meglio
  • 1,646
  • 2
  • 17
  • 33
1
2