Questions tagged [multithreading]

Multiple concurrent streams of execution, commonly known as threads, enable a computer or program to carry out tasks concurrently and asynchronously. Feel free to ask any queries related to the concept of multi-threading and its impact.

Traversing through different levels of a DataFrame to apply filters

I am working with a DataFrame that contains the following data in a csv format: NAME,VENUE_CITY_NAME,EVENT_LANGUAGE,EVENT_GENRE satya,Pune,Hindi,|COMEDY|DRAMA| Amit,National Capital Region,English,|ACTION|ADVENTURE|SCI-FI| satya,Mumbai,Hindi,|COMEDY|DRAMA ...

Utilizing asynchronous functions as callbacks with threading.Timer

I’m running into issues while trying to use the threading package in Python. My goal is to create a Discord bot that sends a message after a certain amount of time has passed. Previously, I used time.sleep(), but it caused my bot to be unresponsive for a ...

When using Selenium async script in its own thread, it can interrupt the execution of other

Let's consider this situation: Various scripts need to run in the browser. One of them involves sending messages from one browser to another (WebRTC). I am interested in measuring the delay for each operation, especially when it comes to sending messages. ...

What causes confusion in Python when dealing with thread arguments?

I created a basic thread program: import threading Initializing threads class OpenThread (threading.Thread): def __init__(self, threadID): threading.Thread.__init__(self) self.threadID = threadID def run(self): prin ...

What are the steps to start running the while loop?

To provide more clarity: I am developing an intersection control system for cars where each car must register its address in a shared list (intersectionList) if it intends to cross the intersection. If cars are on road piece 20 or 23, they add their addre ...

Utilizing Firebase Firestore Transactions and Multithreading in Python

My python script is based on the examples provided on this link. In particular: transaction = db.transaction() city_ref = db.collection(u'cities').document(u'SF') @firestore.transactional def update_in_transaction(transaction, city_r ...

Tips for achieving thread safety with Selenium WebDriver in C#

Despite my efforts to search on Google, I was unable to find a solution. I am seeking help as I have found a solution in Java but not in C#. private static final ThreadLocal < WebDriver > webDriver = new ThreadLocal < WebDriver > () { ...

"Error: accessing local variable before assignment" in a multi-threaded environment

Encountering an issue with a piece of code that runs inside a Python thread. The code functions properly until the number of threads exceeds 100 or 150, at which point multiple threads produce the following error: resp.read(1) UnboundLocalError: local ...

"Python Static Thread Variable: Managing Shared Data in Python

In my software, there are multiple threads performing similar tasks but with different perspectives. The "StateModel" object is crucial for these threads, yet each thread requires a unique calculation of this object. I'd prefer not to pass the StateM ...

What is the method to initiate a fresh instance of Selenium Webdiver for every thread in a Parallel.ForEach loop?

I am interested in running a parallel execution of a web crawler using Selenium ChromeDriver. Encountering problems when attempting to use the same instance of ChromeDriver within a ForEach loop. When trying to access attributes of an HTML document, the ...

Python implementation of Selenium with Multithreading

After creating a Python test script to assess the functionality of a website, specifically focusing on actions like logging into the webpage, I decided to incorporate multithreading. This way, I could run multiple test cases simultaneously and speed up the ...

What is the recommended dispatch_async method for populating a table view controller with JSON data?

I have some JSON data that I need to display in a table view. What is the best approach for fetching and loading this data in the background using dispatch methods or child threads? ...

Using C# to transmit data to JavaScript and awaiting the result for further processing

Is it possible to transfer data from C# to JS, perform an action in JS, and then return the result back to the C# code? I am currently working on a MVC project and I am attempting to encrypt the password in the view before sending it to prevent unauthoriz ...

Using ThreadLocal<RemoteWebDriver>, the FluentWait feature in Selenium allows for seamless synchronization between the test

I am currently seeking a solution to incorporate FluentWaits into my Java Selenium test. The issue I am facing stems from using ThreadLocal to declare my drivers as thread-local in order to run them concurrently. Below is the code snippet in question: // ...

Using SQLAlchemy connection pooling with multiple concurrent threads

To start off, I am creating a basic table structure: import threading from sqlalchemy import create_engine from sqlalchemy import Column, Integer, Float, String, Date, DateTime, Boolean, select from sqlalchemy.ext.declarative import declarative_base from ...

Is multiprocessing the answer?

Imagine having a function that retrieves a large amount of data from a device each time it is called. The goal is to store this data in a memory buffer and when the buffer reaches a certain size, another function should come into play to process it. Howeve ...

New York City worker threads encounter a ReferenceError: cov_vyj5vtdds is not defined

I encountered an error in my code while attempting to calculate the test coverage of my project using nyc. To create a pool of worker threads, I'm utilizing the node-worker-threads-pool library. In order to replicate this behavior, I created a simple exam ...

Aborting ASP.net page's SQL query

For the past week, I've been working on solving a problem that involves creating 2 buttons - "Execute" and "Cancel". Clicking "Execute" triggers a lengthy SQL query, while clicking "Cancel" should stop the query. The issue arises when two ajax queries ...

Maximizing Python efficiency - the ultimate strategy for parallel computing

I am currently developing a Python script that requires sending over 1500 packets simultaneously within less than 5 seconds each. In essence, the main requirements are: def send_packets(ip): #craft packet while True: #send packet ...

Utilizing the RLock mechanism within a shared object

I currently have two threads that both need to access a shared object. To safeguard this object's data, I've structured it in the following manner: class SharedObject: def __init__(self): self.lock = threading.RLock() self.da ...

What is the best way to retrieve the worker ID in Loopback?

After executing the command NODE_ENV=production slc run Loopback will initiate workers for each CPU core automatically. I have a piece of code that I only want to run once, but it ends up running in every worker. Is there a way to determine which speci ...

Is there a way to secure a file in C# without rendering it unwriteable once it has been accessed for the first time

Inspired by a related thread on Stack Overflow discussing how to lock a file using C#, this question delves into the process of locking a JSON file for reading, writing, and unlocking. The proposed method involves utilizing solutions from the mentioned dis ...

Python: Getting results from a function executed in a separate thread

I am working on a piece of code that is used to extract the title of an .MP3 file def retrieveTitle(fileName): print "getTitle" media = MP3(fileName) try: title = str(media["TIT2"]) except KeyError: title = os.path.basenam ...

Ways to execute a singular python function concurrently on multiple occasions

I am looking to run a Python function in parallel 100 times. Can anyone provide the code snippet to achieve this? from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium import webdriver from selenium.webdriver.chrome ...

Implementing Threading in Python/Thread Execution

As a beginner, I've set out to create my first threaded script which will eventually function as a web scraper with improved speed compared to my previous linear scraping script. Despite hours of research and tinkering with example code, I'm still uncertai ...

What is the process for recreating a thread with different parameters?

I am working on a multithreading program that sends emails to my clients. However, I am facing some issues with the threads in my code - they only close the window of Firefox and do not continue the desired actions. I am looking to create an algorithm wher ...

Working with Parallel Threads in C# for Selenium Automation

Seeking to automate the testing process for one of my websites using Selenium with C#. The website requires user login credentials and must be accessed through multi-threading. One thread is used to open the page in a specialized Firefox profile, while ano ...

HTML5 canvas processing causing web worker to run out of memory

Within the Main thread: The source image array is obtained using the getImageData method. It is represented as a uint8ClampedArray to store the image data. Below is the code executed in a web worker: (This operation generates a high-resolution image, but ...

Unable to close Asynchronous Web.py Web Server

Referring to this example, I am curious why it's not possible to terminate this program using Ctrl+C: #!/usr/bin/env python import web import threading class MyWebserver(threading.Thread): def run (self): urls = ('/', 'MyWebse ...

Developing a multithreaded approach to locating elements using Selenium

Looking to optimize my script's performance, I decided to implement multithreading for the more time-consuming parts, particularly the locator calls. However, I encountered "CannotSendRequest" and "ResponseNotReady" exceptions from the threads. Is th ...

What is the correct way to detach and eliminate shared memory between two processes in PHP?

I came up with a method to handle asynchronous tasks in PHP, and so far it has been working really well. The concept is based on utilizing three extensions: PCNTL, POSIX, and Semaphore. In order to maintain complete control over both the master process a ...

Is it advisable to create a separate MongoDB connection for each thread in my application?

Is it more efficient to establish a connection to MongoDB using the Node.js cluster library in the master thread or in each child thread? Can multiple threads share the same connection? Considering performance, would it be better to use a single shared c ...

Looking for a Solution to Secure Files Using Selenium Webdriver During Threading?

Implementing multiple threads to initialize PhantomJS or Chromedriver with the following code: Driver= webdriver.PhantomJS('C:phantomjs.exe',desired_capabilities=dcap, service_args=service_args) or Driver= webdriver.Chrome(executable_path='C:/chromedr ...

Balancing the Demands on a Node

We are currently managing a C# Web API server and a Node Express server. Our C# server sends multiple requests to a specific route on the Node server, which performs complex tasks and often takes 6-8 seconds to complete. However, when we send hundreds of ...

What could be causing my multi-process queue to exhibit un-threadsafe behavior?

I am currently developing a watchdog timer that is responsible for monitoring another Python program. If the watchdog timer fails to receive a check-in signal from any of the threads, it will shut down the entire program. This functionality is essential fo ...

Is it two never-ending cycles taking turns?

Seeking a solution to this particular issue: There are two functions that need to be implemented: def function1(): while True: print("x") def function2(): while True: print("y") The goal is to execute these functions alternately ...

Utilizing Angular: Integrating the Http response output into a map

I have a situation where I am making multiple HTTP calls simultaneously from my Angular application. The goal is to store the responses of these calls in a Map. data: Map<number, any> = new map<number,any>(); --------------------------------- ...

simultaneous execution and writing to files in Python

I am faced with a challenge of handling extremely large datasets spread across 10 major clusters. The objective is to perform computations for each cluster and write the results line by line into separate files. Each file will contain the results corresp ...

Why is it that all my workers in node.js respond to a single incoming request?

In my current setup, I am utilizing node in combination with express as the web server, operating with a total of 4 workers within a cluster. The issue arises when an incoming request triggers responses from all workers. Each worker serves the same web ap ...

Deliver a whopping one million messages to the queue within sixty seconds

I'm currently utilizing rabbitMQ for message reception. I have a million messages that need to be sent to the queue within a minute. Using multiprocessing in Python, my code is taking more than 5 minutes to send them all out. Is it feasible to achieve ...

Which is better for a web automation bot in Python: Multithreading or Multiprocessing?

I have a script that continuously monitors the prices of specific products on nike.com. Once the price drops, it will automatically initiate multiple instances to log in and purchase the item from different accounts. While I already have the scraping and ...

Unraveling Intertwined Loops in Python

I've created a program that can ping multiple IPs simultaneously by sending 10 pings and recording the results in a dictionary while also displaying the status on a webpage. However, I am looking to update the program so that it can continuously ping ...

The use of Python threads in conjunction with os.system() calls can lead to the main thread not properly exiting when a ctrl+c

Before jumping to conclusions, please take a moment to read through this question. While there are many inquiries about multithreading and keyboard interrupts, I have yet to come across one that considers the use of os.system, which seems quite significant ...

Exploring the options between threading and multiprocessing when using Selenium for web scraping

For a scraping task involving many JavaScript-generated webpages, I am using Selenium. I have the capability to open multiple instances of the WebDriver simultaneously and pass different websites to each instance via a queue. There are various ways to acc ...

What is the process for developing a multi-threaded ASP.NET Ajax update panel?

Hey there, I was wondering if you could provide some insights on how to develop a multi-threaded ASP.NET AJAX update panel? Your help would be greatly appreciated! ...

Creating a Node server that can handle multiple websites, with each site running on its own dedicated thread

I have a laptop that is running Node on it, specifically an Ubuntu Server with a quad-core processor. Currently, there are plans to host 2-3 sites on this server. However, I'm not very proficient in system administration and need assistance in settin ...

What could be causing the lack of responsiveness in matplotlib?

While utilizing an IPython notebook with: ipython notebook --pylab If I am executing a CPU intensive code, the previous matplotlib figures become unresponsive. Is there a method to run matplotlib on a separate thread? I have experimented with the ion() c ...

What is the best way to restrict the number of threads in a TestNG dataprovider method functioning as a factory?

My current testing setup involves using Selenium to test a single-page application. I load the page in a @beforeClass method and then run all the tests within the class. Finally, I tear down the driver in the @afterClass method. To facilitate browser setu ...

Python - when there is a lengthy loop running, how can a thread be used to periodically perform an action within the same scope?

Imagine a scenario where I am running a loop that involves reading a lengthy file. How can I ensure that at regular intervals, let's say every x milliseconds, a specific "some code" is executed? while inFile.readable(): line = inFile.readline() p ...

What is the method to initiate a Python thread from C++?

In my current project, I am specifically limited to using Python 2.6. The software involves a Python 2.6 application that interfaces with a C++ multi-threaded API library created with boost-python. I have been trying to implement a Python function callback ...

Encountering a glitch while simultaneously initiating multiple web drivers in Python for multi-threaded processing

My current project involves web scraping using Python, and I'm attempting to implement multi-threading to enhance the speed of the process. To achieve this, I plan to utilize selenium. The strategy is to open a separate webdriver for each thread. Init ...

Executing multiple jar files in Python using multithreading results in longer execution times

I am currently utilizing ThreadPoolExecutor and assigning identical tasks to workers. The task involves running a jar file and performing certain operations on it, but I have encountered an issue related to timing. Scenario 1: When I submit a single task ...