Questions tagged [Asynchronous programming] (280)

0
answer

How to throw errors in a try/catch block inside the async function?

There is such code: async function () { try { const response = await doAsyncOperation(); if (response.isError) { throw new Error(response.isError) } return 'All good' } catch (err) { console.log(err); return 'Error happened' } } Here I'm trying to check whether response error, and if so, throw an error (thereby it should ...
Keyshawn.Ha asked April 19th 20 at 12:09
1
answer

As an asynchronous program(event loop) realizes that the answer came from the server?

As an asynchronous program(event loop) understands that a function(method) received the response from the server and it should transfer control? To do this it uses another thread or event loop at a certain stage checks readiness tasks?
Granville_Koz asked April 19th 20 at 12:03
1
answer

The timeout for asynchronous request js. How best to implement?

There is an asynchronous request js to the server, which responds after 5 seconds. How do I reset it on timeout after 2 seconds. I mean if a request lasts longer than 2 seconds, don't wait for an answer. Because the query has already got a callback and will be executed.
Jerami asked April 19th 20 at 11:56
1
answer

Why is the console consoleconsole the console? And what was the fix?

console console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consoleconsole console consolecon...
brayan1 asked April 18th 20 at 12:46
1
answer

Why not to upload a photo in Facebook?

There is such code. It works to asynchronously load images on the server, but I don't want to create unnecessary files, so I use BytesIO import ... image_url = '...' vk_session = vk_api.VkApi(token=TOKEN) api = vk_session.get_api() upload_url = api.photos.getMessagesUploadServer()['upload_url'] with open('/tmp/photo.jpg'...
dana10 asked April 18th 20 at 12:45
2
answers

Should the telegram bot to be asynchronous?

I have a telegram bot that receives from the user the LaTeX code and render it via the utility pdflatex, which is run through os.system(...) Rendering takes a few seconds. Do I understand correctly that at the time of rendering the bot "hangs", and to get rid of this problem you need to run the render asynchronously?
Carlo asked April 16th 20 at 10:47
0
answer

Asynchronous message handling, bot VC, than to implement?

There is a handler for new messages in the VC group. Here is the piece of code responsible for this: #function that adds to the dictionary with the user ID request. def vvod(znk, bib): dict_id[messages['items'][0]['last_message']['peer_id']][znk] = [bib[event.object.text]] while True: try: for event in add.listen(): if...
tyrese.Quitz asked April 16th 20 at 10:39
0
answer

Why debugger is not reaching the catch then?

There is a component InputArea import React {Component} from 'react'; import from axios 'axios'; class InputArea extends Component { constructor(props) { super(props); this.state = { text: " }; this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); } handleChange(event) {...
eloise.Towne82 asked April 9th 20 at 09:32
4
answers

What to study to create a web application (server) that can send requests to your customers (not Vice versa)?

Usually we send the request to the server and it returns the result. How to do the opposite? For example, chat rooms. I am interested in the development in which the web server can send requests to your customers (sites). Examples: VC, catici, instagram, and things like that here. I tried to learn a little about the topic...
Javonte_Dicki asked April 9th 20 at 09:29
3
answers

What to use for receiving TCP packets in python?

Help to choose the right tool to solve the problem. You need to take the data from many similar devices have their own Protocol on top of TCP, and add them to the database. Before that, never worked with the network on this level, only with http. Yet googled what to use streams from asyncio and raise my TCP server, but has...
Israel44 asked April 8th 20 at 17:54