Questions tagged [concurrent.futures]

concurrent.futures is a Python module which provides a high-level interface for asynchronously executing callables.

The concurrent.futures module aims to provide a simple interface for parallelizing operations in multi-threaded and multi-process Python applications. The module was added to the Python standard library in version 3.2, but a backport is available for Python 2.5+.

929 questions
0
votes
1 answer

Trying to setup a rethinkDB connection with tornado and getting AttributeError: 'Future' object has no attribute '_start'

I am trying to setup rethinkDB with tornado. This is my db setup - db_connection = r.connect(RDB_HOST,RDB_PORT) #Connecting to RethinkDB server This is just for cross-checking database and table exists def dbSetup(): print…
Ekwinder Saini
  • 270
  • 5
  • 18
0
votes
2 answers

How would I handle a Future[User] versus a Future[Option[User]]?

What is the difference in how you handle a Future[User] versus a Future[Option[User]]? I am also confused as I kind of thought a flatMap removes Options, but is that restricted to them being in a collection?
cool breeze
  • 4,461
  • 5
  • 38
  • 67
0
votes
1 answer

Parallel compute task to brute-force in python

/* This is not for anything illegal just that my school only uses 7 integers, and I want to see if I can get this to work in time as currently I need 1.59 years to crack a password. The school has it's own private server on site for anyone concerned…
user5327424
0
votes
2 answers

CPU Implications for FutureTask.awaitDone

We use the Java ThreadPoolExecutor extensively. Specifically, we follow a fork join pattern, with building a list of callables and using the timed variant of invokeAll() on them. We only use these thread pools to perform I/O (non CPU intensive)…
RPJ
  • 39
  • 3
0
votes
1 answer

Future map's (waiting) execution context. Stops execution with FixedThreadPool

// 1 fixed thread implicit val waitingCtx = scala.concurrent.ExecutionContext.fromExecutor(Executors.newFixedThreadPool(1)) // "map" will use waitingCtx val ss = (1 to 1000).map {n => // if I change it to 10 000 program will be…
ses
  • 13,174
  • 31
  • 123
  • 226
0
votes
2 answers

How to wait until an async method finishes using Futures?

I have an async Retrofit-based API call in Android and need to wait with the DB calls until the API call finishes, so that I am sure the proper data gets entered into the DB. I read that you can use Futures to accomplish this task, however with my…
0
votes
1 answer

future executor not performed

The future does not get called in the following snippet: def main(): if not amiadmin(): print ("You are not superuser") raise PermissionError dumpfile = open('filename', mode='w') fileiolock = threading.RLock() (ip,)…
Erkin Alp Güney
  • 218
  • 6
  • 15
0
votes
0 answers

Python's `concurrent.futures` Threadpool- can be called by several functions

I'm looking to create a thread pool mechanism which will limit the number of threads in the system in any given time. I have a several functions creating many threads and i want to create mutual thread pool for that. From what i understood once a…
0
votes
1 answer

Iterating map of Future objects and call their get function

I'm having a hard time interating a HashMap>: for (Entry> entry : map.entrySet()) { logger.debug("Thread: " + entry.getKey() + "/" +…
Erando
  • 811
  • 3
  • 13
  • 27
0
votes
1 answer

Python - Read a map with concurrent.futures

In order to decrease the time of my calculations, in following post, someone told me to use map with concurrent.futures. But i can t read the results, i get "generator object map at 0x7f0ef48ff2d0>"...how can i do that? import…
user3601754
  • 3,792
  • 11
  • 43
  • 77
0
votes
1 answer

Tornado Future object dumps to Redis and loads from Redis

I was developing a Push System with Tornado. As i'm taking long polling, i need to keep a list of Future Object in order to set results for them later. Then i want to keep the Future list in Redis, so i 'dumps' each Future with Pickle module and set…
yunfeng.guo
  • 175
  • 1
  • 11
0
votes
1 answer

Vector of futures for breaking up tasks?

I have a response from a web service that if the number of data items is large, I want to split it up into smaller requests and perform the request and subsequent parsing of that request in parallel. Essentially, while the first request is parsing…
user3072517
  • 513
  • 1
  • 7
  • 21
0
votes
0 answers

Concurrency in recursive function

I have function like this def jsonFlatten(obj: JsValue, coun: JsObject = Json.obj(), pref: String = ""): JsObject = { var con = coun var kel = "" var el: JsValue = Json.obj() obj match { case JsObject(_) => var ob =…
ans4175
  • 432
  • 1
  • 9
  • 23
0
votes
2 answers

Scala, Futures, WS library, Api

I have Play! on Scala application which communicates with another server by sending http request. That system has limitation: only 5 http requests can be proceeded simultaniously for one token. I've written this method: import…
Alexander Kondaurov
  • 3,677
  • 5
  • 42
  • 64
0
votes
1 answer

Using Python's concurrent.futures to process objects in parallel

I just started using the library concurrent.futures from Python 3 to apply to a list of images a number of functions, in order to process these images and reshape them. The functions are resize(height, width) and opacity(number). On the other hand,…