task

SQLAlchemy session handling in delayed Celery tasks

故事扮演 提交于 2019-12-11 13:58:08
问题 I am using a relational database via SQLAlchemy. I want to spawn a job that deals with databases using Celery. There is a code: from sqlalchemy.orm.session import Session from celery.task import task from myapp.user import User @task def job(user): # job... session = Session.object_session(user) with user.begin(): user.value = result_value def ordinary_web_request_handler(uid): assert isinstance(session, Session) user = session.query(User).get(int(uid)) # deals with user... job.delay(user)

Jagged array of tasks - Concurrency Issues

偶尔善良 提交于 2019-12-11 13:54:08
问题 I am defining a jagged array of threads (such that each thread can operate on the directory tree of its own) in this manner Task[][] threads = new Task[InstancesDir.Length][]; for (int i = 0; i < InstancesDir.Length; i++) { threads[i] = new Task[InstancesDir[i].Length]; } for (int i = 0; i < FilesDir.Length; i++) { for (int j = 0; j < FilesDir[i].Length; j++) { threads[i][j] = Task.Run(() => { Calculate(i, j, InstancesDir, FilesDir, PointSum); }); } Task.WaitAll(threads[i]); } But in

ANT checkout task fails

人走茶凉 提交于 2019-12-11 13:41:48
问题 I've got the following markup: <?xml version="1.0" ?> <project name="SampleBuild" default="compile" basedir="."> <property name="SvnAntDir" value="C:/Program Files/Apache/svnant-1.2.1/doc" /> <property name="src" value="_src_" /> <property name="build" value="_build_"/> <property name="dist" value="${build}/_jars_" /> <path id= "svnant.classpath" > <fileset dir= "${SvnAntDir}" > <include name= "*.jar" /> </fileset> </path> <target name="pre-cleanup"> <delete dir="${src}" /> <delete file="$

Creating async selects to WMI and wait to their completion

对着背影说爱祢 提交于 2019-12-11 12:45:34
问题 I read a lot of posts about async methods, but still... I'm a little confused about this. So maybe someone can help me with my case. Right now my code doesn't throw any error, but I know that my code is not good, cause I use async void and I can't wait for all my task to be completed. So, can someone please help me edit this code: In my form class, I create Relation: Relation rel = new Relation(cb_MachineToConnect.Text); In Relation class: public Relation(string machineAddress) { isAsctive =

Python: Implementing concurrent DNS requests (pipelining)

断了今生、忘了曾经 提交于 2019-12-11 12:38:40
问题 I'm trying to write a python script that sends multiple DNS requests, using a different name server for each request. Implementing a sequential solution is easy using dnspython but too slow for me. Adding concurrency using thread pool is not possible as, in my particular case, all requests use the same source port (REUSE_ADDRESS won't help here either). For the above reasons I'm thinking about using the following solution (ditching the use of dnspython's resolver module but taking advantage

Using thousands of Tasks with a timeout efficiently

对着背影说爱祢 提交于 2019-12-11 12:18:38
问题 I am implementing a Library L that communicates via Sockets with another application A. Basic workflow is as followed: L connects to A. L sends ~50.000 pieces of information I to A, and creates a task T for every I that is sent out. L listens for incoming results from A, and once reuslts are there, uses a TaskCompletionSource to set the results of the Tasks T L creates a Task T2 with a set Timeout (Task.WhenAny(T,Task.Delay(xx)) L uses Task.WhenAll(T2) to wait for timeout or results on all

Task.wait not working as I imagined

雨燕双飞 提交于 2019-12-11 11:40:34
问题 I am trying to download a file, wait for the file to finish downloading, and then read the file afterwards. I have the following methods to do this: private async Task startDownload(string link, string savePath) { WebClient client = new WebClient(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); await client.DownloadFileTaskAsync(new Uri

Passing a Vec<Struct> into a new task

巧了我就是萌 提交于 2019-12-11 11:37:12
问题 Im attempting to pass a Vector of a custom struct into a function that is executed in a new task. I've implemented the Clone trait, which I thought was needed for this, but apparently the vector I want to pass in needs to implement 'static+Send in order to be captured in the closure's environment. I'm not exactly sure how to go about satisfying those lifetime specs? I'm attempting to start the process from this function pub fn start(server: Server, ip: &str, port: u16) { // Other things

What is difference between Task.Factory.StartNew and new Thread().Start()? [duplicate]

試著忘記壹切 提交于 2019-12-11 11:02:59
问题 This question already has answers here : What is the difference between task and thread? (8 answers) Closed 5 years ago . I have one DbContext (Entity Framework 6.0) and 1,000 objects. For each object, I start to save its into database or update its data with a separate thread/task using the same DbContext. This is what I got: For thread: EntityCommandExecutionException - There is already an open DataReader associated with this Command which must be closed first. This exception occurred right

Correct way to link Tasks together when return values are needed at different times

↘锁芯ラ 提交于 2019-12-11 10:28:20
问题 I hope this makes sense - Suppose I have the following code: Task.Run(() => { return Task.WhenAll ( Task1, Task2, ... Taskn ) .ContinueWith(tsks=> { TaskA (uses output from Tasks Task1 & Task2, say) } , ct) .ContinueWith(res => { TaskB (uses output from TaskA and Task3, say) } , ct); }); So I want all my first N tasks to run concurrently (since we have no interdependencies), then only once they're all finished, to continue with a task that relies on their outputs (I get that for this, I can