Is there a way to obtain a unique ID for the current thread? I have an
object that I need to store local thread data in, and I don't want to
use threading.local because each thread might have multiple instances
of my object. 4 4024
Benjamin schrieb:
Is there a way to obtain a unique ID for the current thread? I have an
object that I need to store local thread data in, and I don't want to
use threading.local because each thread might have multiple instances
of my object.
You can use the thread itself, it's usable as key (that's what
threadlocals use for their implementation anyway)
But I don't understand your problem - all thread-local implementations I
know of (is there a standard?) can be instantiated in each object and
then offer a get/set method (keyed or not) - but without interfering
with outher instances of themselves of course.
Diez
Benjamin wrote:
Is there a way to obtain a unique ID for the current thread? I have an
object that I need to store local thread data in, and I don't want to
use threading.local because each thread might have multiple instances
of my object.
threading.get_i dent() but please use threading.local . Nobody is going to
stop you if you use a list or dict in threading.local .
Christian
On Jan 18, 2:31 am, Christian Heimes <li...@cheimes. dewrote:
Benjamin wrote:
Is there a way to obtain a unique ID for the current thread? I have an
object that I need to store local thread data in, and I don't want to
use threading.local because each thread might have multiple instances
of my object.
threading.get_i dent() but please use threading.local . Nobody is going to
stop you if you use a list or dict in threading.local .
then, I have to figure out how to represent an instance of my object
in threading.local . (The data also won't be garbage collect when my
object is, will it?) I think the unique id is elegant in this case.
>
Christian
En Fri, 18 Jan 2008 22:41:47 -0300, Benjamin <mu************ **@gmail.com>
escribió:
On Jan 18, 2:31 am, Christian Heimes <li...@cheimes. dewrote:
>Benjamin wrote:
Is there a way to obtain a unique ID for the current thread? I have an
object that I need to store local thread data in, and I don't want to
use threading.local because each thread might have multiple instances
of my object.
threading.get_ ident() but please use threading.local . Nobody is going to stop you if you use a list or dict in threading.local .
then, I have to figure out how to represent an instance of my object
in threading.local . (The data also won't be garbage collect when my
object is, will it?) I think the unique id is elegant in this case.
I think you didn't get how threading.local works yet. It's a lot easier
than you imply. Just store your instances as attributes of a
threading.local object. You may use a list or dictionary if you want
multiple instances.
Read _threading_loca l.py, it contains a lot of examples.
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Claudio Jolowicz |
last post by:
Is it possible to store unique objects in an STL container?
Suppose an object of class C is unique:
class C
{
public:
C() {}
~C() {}
private:
|
by: Jozef |
last post by:
Hello,
Is there any way to acquire a unique Machine ID, Hard Drive ID or Windows
Installation ID? Im looking for a way to uniquely identify a physical
installation and connection. The problem with using user names is that the
user can travel in the network. The problem using machine name is that
there can be two of the same machine name on the network (using TCP/IP only
, no Netbeui).
Any help would be great! Thanks!
|
by: Abhishek |
last post by:
Hi!
I need to create a unique password everytime i click a button .
what technique/Algo should i follow.
Abhishek
|
by: Jerry LeVan |
last post by:
Hi,
I am futzing around with Andrew Stuarts "Catchmail" program
that stores emails into a postgresql database.
I want to avoid inserting the same email more than once...
(pieces of the email actually get emplaced into several
tables).
Is the "Message-ID" header field a globally unique identifer?
|
by: JJ |
last post by:
Now I know this question has been asked many times, but I cannot seem to
find a good site which summarises the methods possible in vb .net.
I am after a way of producing a unique serial number for my app. The program
would produce a unique identifier for the computer, then I would psovide the
user with a serial number unique to their machine.
In other words I would like to check for things like:
i) Hard disk (not volume) serial number...
| |
by: Laurence |
last post by:
Hi there,
How to differentiate between unique constraint and unique index? These
are very similar but I cannot differentiate them?
Could someone give me a hand?
Thanks in advance
|
by: tony obrien |
last post by:
Hi,
I have written a Class Library in VB.net which provides Props/Meths to a
caller to hide the uglinesses of a TCP message protocol between a Client
and a Server.
All this works just fine.
Now I am trying to develop a LOAD TESTER app which spawns lotso' threads
each with this capability to bang the server.
|
by: sqlservernewbie |
last post by:
Hi Everyone,
Here is a theoretical, and definition question for you.
In databases, we have:
Relation
a table with columns and rows
|
by: pkchandra999 |
last post by:
My Server OS : Centos 64 bit
Apache version is Apache v2.2.9
Php Version : 5.2.5
I am providing feeds to my forum through RSS.
The feeds are in html and those feeds will be parsed to bbcode of the forum.
In my forum the feeds are not parsed to bbcode and it actually posting the html code into the thread in a strange way. IT is removing the <> tags for each html code and posting it in thread.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |