Comments (3)
This is a very special case which occurs, as far as I can deduce, only when you make the queue fit exactly one element. This is far from the use cases this package is considered for, however if it proves necessary, I can try to figure out a consistent way to handle this.
For sharing a single array, consider a thin wrapper around the multiprocessing Array class, like ArrayView in this package.
Lastly, if you use threading, this is not even necessary, as due to the python global interpreter lock only one thread per process is allowed. So there are no real separate threads and no need arises to consider memory sharing, as I think all memory should be accessible to all "threads", of course without the parallelization benefits.
from arrayqueues.
I tried increasing the queue size so that it was 4x as large as the array i was storing in the queue. This test code (which has an infinite loop that gets, then puts an array) will crash in about 10 seconds. I increased the queue buffer to 8x the array size i was inserting, and i was able to get the test code to run without crashing. Allocating less memory than this (less memory than 8x the array size) to the arrayqueue would result in a crash. Here is my test code:
from arrayqueues.shared_arrays import ArrayQueue
import threading
import numpy as np
import time
class ReadProcess(threading.Thread):
def __init__(self, queue):
super().__init__()
self.queue = queue
def run(self):
a = self.queue.get()
print("Is queue empty (from child thread): {}".format(queue.empty()))
if __name__ == "__main__":
create_start = time.time()
queue = ArrayQueue(32/1000) # intitialises an ArrayQueue which can hold 32 KB of data
numbers = np.random.uniform(10000, size = 1000) #this is 8 KB in size
numbers_copy = np.copy(numbers)
queue.put(numbers_copy)
thread = ReadProcess(queue)
thread.start()
thread.join()
print("Is queue empty(from main thread): {}".format(queue.empty()))
while True: #infinite loop, this code is used to test for memory crashes
queue.put(numbers_copy)
queue.get()
create_end = time.time()
print("execution time: {}".format(create_end - create_start))
from arrayqueues.
Old issue, this does not seem to be crashing on my machine, I'll close for now.
from arrayqueues.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrayqueues.