asynchronous

Using sets with the multiprocessing module

限于喜欢 提交于 2021-02-08 05:16:28
问题 I can't seem to share a set across processes using a Manager instance. A condensed version of my code: from multiprocessing.managers import SyncManager manager = SyncManager() manager.start() manager.register(Set) I've also tried register(type(Set)) and register(Set()) , but I'm not overly surprised that neither of them worked (the first should evaluate to Class, I think). The exception I get in all cases is TypeError: __name__ must be set to a string object in line 675 of managers.py. Is

Using sets with the multiprocessing module

喜夏-厌秋 提交于 2021-02-08 05:15:16
问题 I can't seem to share a set across processes using a Manager instance. A condensed version of my code: from multiprocessing.managers import SyncManager manager = SyncManager() manager.start() manager.register(Set) I've also tried register(type(Set)) and register(Set()) , but I'm not overly surprised that neither of them worked (the first should evaluate to Class, I think). The exception I get in all cases is TypeError: __name__ must be set to a string object in line 675 of managers.py. Is

Asyncio execution flow issue

梦想与她 提交于 2021-02-08 04:52:12
问题 i am a little new to asyncio in python. I was trying to run this simple code but i don't know why i am getting this unexpected output. What i did is that, in outer function, i created async tasks and stored it in an array tasks . Before awaiting on these tasks i wrote a print statement print("outer") that should run in every iteration. And inside the task i wrote another print statement print("inner") in inner function. But some how i am getting some unexpected output. Here's the code -

async & await - dealing with multiple calls to same method - locking/waiting on each other?

扶醉桌前 提交于 2021-02-08 03:38:06
问题 I had a complex Task/lock based mess for performing a 'long' data operation, and I'm trying to replace it with an async/await. I'm new to async await, so I'm worried I'm making some big mistakes. To simplify things, my UI has a few pages that depend on the same data. Now, I only need to get this data once. So I cache it, and further calls just grab it from the cache "CachedDataObjects" rather than doing the long call every time. Like this (semi-pseudocode): private Dictionary<Guid,List<Data>>

async function declaration expects ';' in Internet Explorer

守給你的承諾、 提交于 2021-02-08 03:01:46
问题 I have an async function declaration that works on Chrome and Firefox, but gives the following error in internet explorer. SCRIPT1004: Expected ';' File: javascriptFile.js, Line: 5, Column 7 This is the simplified version with these two function at the top of the file, and it still fails on internet explorer. function sleep (ms) { return new Promise(function (resolve) { setTimeout(resolve, ms) }) } async function begging (help) { await sleep(1000) console.log('please') } I can not seem to

Swift: Multiple async requests in order. How to wait for previous request to finish?

空扰寡人 提交于 2021-02-07 20:30:45
问题 As part of the authentication process in my app, users can sign in using their Facebook account - I'm using the Facebook iOS SDK to handle this process. Once authentication is complete, I make a request to Facebook graph api to fetch the users profile data (This is the first async req). The second async request is also to Facebook graph api to request the users friends list who have the app installed. The final and third request in this function makes a async POST request to an API I've

Async odbc seems to be synchronous

不羁岁月 提交于 2021-02-07 18:43:24
问题 I'm trying to do async database queries, but when I test my code it appears to be synchronous. I've isolated the issue to my Query function. Can't figure out what I'm doing wrong, I'm pretty new to the aync/await functionality so it's possible that I've done something stupid :) This is the failing code: (i'm using a local install of postgresql) public static void Main() { Task.Run(async () => await MainAsync()).GetAwaiter().GetResult(); } public static async Task MainAsync() { await

List.add() async task await correct syntax

两盒软妹~` 提交于 2021-02-07 18:38:43
问题 Hello I am trying to add items to a list asynchronously but I am not sure how it is done and if I am using an incorrect syntax, this is what I have at the moment: My View: await viewModel.getMessages(); list.ItemsSource = viewModel.Messages; My View Model: public List<Message> Messages { get; set; } public async Task getMessages() { await GetRemoteMessages(); } private async Task GetRemoteMessages() { var remoteClient = new ChiesiClient(); var messages = await remoteClient.getMessages()

Call asynchronous external web service in asp.net MVC controller

假如想象 提交于 2021-02-07 14:57:15
问题 In the Asp.net MVC controller (GET method) I am calling external web service - for geolocation of IP - returning json data for IP location. How can I make the call to be async, hence the stack can continue while waiting the response from the service. When the GEO IP request finished I want to be able to make update to the db. Here is the current sync code: public ActionResult SelectFacility(int franchiseId, Guid? coachLoggingTimeStampId) { //... string responseFromServer = Helpers

Unit testing async method - test never completes

霸气de小男生 提交于 2021-02-07 14:53:49
问题 I'm trying to unit test my a class I'm building that calls a number of URLs (Async) and retrieves the contents. Here's the test I'm having a problem with: [Test] public void downloads_content_for_each_url() { _mockGetContentUrls.Setup(x => x.GetAll()) .Returns(new[] { "http://www.url1.com", "http://www.url2.com" }); _mockDownloadContent.Setup(x => x.DownloadContentFromUrlAsync(It.IsAny<string>())) .Returns(new Task<IEnumerable<MobileContent>>(() => new List<MobileContent>())); var