Does any one now if a shared memory module exists, written in python
for a windows platform. I now one exists for unix?
help most appreciated,
S Green 14 24947
S Green wrote: Does any one now if a shared memory module exists, written in python for a windows platform. I now one exists for unix?
Your first message with this same question did in fact make it to
Usenet and the mailing list.
Generally speaking, you should allow several days for answers to questions,
rather than getting anxious just because ten people don't jump up and answer
it in the first few hours.
(And my guess is that one doesn't exist, as Windows shared memory would
probably be a completely unreliable bitch, but that's just my guess. :-)
-Peter st***********@b aesystems.com (S Green) writes: Does any one now if a shared memory module exists, written in python for a windows platform. I now one exists for unix?
help most appreciated,
S Green
import mmap
Thomas Heller wrote: st***********@b aesystems.com (S Green) writes:
Does any one now if a shared memory module exists, written in python for a windows platform. I now one exists for unix?
help most appreciated,
S Green
import mmap
The docs suggest that mmap.mmap(x, x, mmap.MAP_SHARED ) will work under
Unix but not Windows.
Does the Windows version really support shared memory, or is the
multiple-maps-per-file feature only valid within a single process?
-Peter
Peter Hansen <pe***@engcorp. com> writes: Thomas Heller wrote: st***********@b aesystems.com (S Green) writes:
> Does any one now if a shared memory module exists, written in python > for a windows platform. I now one exists for unix? > > > help most appreciated, > > S Green
import mmap
The docs suggest that mmap.mmap(x, x, mmap.MAP_SHARED ) will work under Unix but not Windows.
Does the Windows version really support shared memory, or is the multiple-maps-per-file feature only valid within a single process?
Yes, it does. You have to give this memory block a name, though:
sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory")
This allows to access 16384 bytes of memory, shared across processes,
not backed up by a file in the filesystem.
Thomas
Thomas Heller wrote: Peter Hansen <pe***@engcorp. com> writes:
Thomas Heller wrote: st***********@b aesystems.com (S Green) writes:
> Does any one now if a shared memory module exists, written in python > for a windows platform. I now one exists for unix? > > > help most appreciated, > > S Green
import mmap
The docs suggest that mmap.mmap(x, x, mmap.MAP_SHARED ) will work under Unix but not Windows.
Does the Windows version really support shared memory, or is the multiple-maps-per-file feature only valid within a single process?
Yes, it does. You have to give this memory block a name, though:
sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory")
This allows to access 16384 bytes of memory, shared across processes, not backed up by a file in the filesystem.
Thanks, Thomas.
In my opinion the documentation on this is entirely unclear. I attach
it for reference, but I can't offer any suggestions for improvement (as
I don't know anything about shared memory) except that even after reading
it a second time, Thomas' answer above is very much news to me:
'''tagname, if specified and not None, is a string giving a tag name
for the mapping. Windows allows you to have many different mappings
against the same file. If you specify the name of an existing tag,
that tag is opened, otherwise a new tag of this name is created. If
this parameter is omitted or None, the mapping is created without a
name. Avoiding the use of the tag parameter will assist in keeping your
code portable between Unix and Windows. '''
(from http://www.python.org/doc/current/lib/module-mmap.html)
-Peter
Thomas Heller wrote: Does the Windows version really support shared memory, or is the multiple-maps-per-file feature only valid within a single process?
Yes, it does. You have to give this memory block a name, though:
sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory")
This allows to access 16384 bytes of memory, shared across processes, not backed up by a file in the filesystem.
That is très cool, it doesn't tell you this in the docs, does it?
The first argument is 'the file handle' of the file to be mapped,
and it doesn't say that 0 is valid and means 'no file at all'...
However, I've just tried it, and managed to crash Python in mmap.pyd
with an application exception... twice. But trying to reproduce it
now fails-- Python keeps running.
I did this: import mmap mem=mmap.mmap(0 ,3000000,'irmen ') mem[0]='a' mem[2000000]='a'
and initially, it crashed........ . Python 2.3.2 on win xp)
--Irmen
Irmen de Jong <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> writes: Thomas Heller wrote:
Does the Windows version really support shared memory, or is the multiple-maps-per-file feature only valid within a single process? Yes, it does. You have to give this memory block a name, though: sharedmem = mmap.mmap(0, 16384, "GlobalSharedMe mory") This allows to access 16384 bytes of memory, shared across processes, not backed up by a file in the filesystem.
That is très cool, it doesn't tell you this in the docs, does it? The first argument is 'the file handle' of the file to be mapped, and it doesn't say that 0 is valid and means 'no file at all'...
However, I've just tried it, and managed to crash Python in mmap.pyd with an application exception... twice. But trying to reproduce it now fails-- Python keeps running. I did this: >>> import mmap >>> mem=mmap.mmap(0 ,3000000,'irmen ') >>> mem[0]='a' >>> mem[2000000]='a'
and initially, it crashed........ . Python 2.3.2 on win xp)
This works for me even from the beginning (with 2.3 CVS version, XP Pro).
Understading which parameters to pass apparently requires
- reading the mmapmodule.c sources
- and reading about CreateFileMappi ng and MapViewOfFile in MSDN.
It would be great if someine could submit a patch for the docs <wink>.
I vaguely remember, but am not able to find it anymore: didn't AMK once
had an article about this somewhere?
Thomas
Irmen de Jong wrote: However, I've just tried it, and managed to crash Python in mmap.pyd with an application exception... twice. But trying to reproduce it now fails-- Python keeps running. I did this: >>> import mmap >>> mem=mmap.mmap(0 ,3000000,'irmen ') >>> mem[0]='a' >>> mem[2000000]='a'
and initially, it crashed........ . Python 2.3.2 on win xp) --Irmen
Probably not enough actual memory hanging around. Some systems
(and from this I'd guess XP) allocate virtual memory by reserving
address space, not actually allocating the RAM and/or backing
store for that memory. Python has no control over this, and you
have nothing good to do if the memory is over-allocated. When
you create the memory, you could walk across it writing into it
(forcing it to exist), but that would just force the failure to
happen earlier.
-Scott David Daniels Sc***********@A cm.Org
Scott David Daniels wrote: Irmen de Jong wrote:
However, I've just tried it, and managed to crash Python in mmap.pyd with an application exception... twice. But trying to reproduce it now fails-- Python keeps running. I did this: >>> import mmap >>> mem=mmap.mmap(0 ,3000000,'irmen ') >>> mem[0]='a' >>> mem[2000000]='a' and initially, it crashed........ . Python 2.3.2 on win xp) --Irmen
Probably not enough actual memory hanging around. Some systems (and from this I'd guess XP) allocate virtual memory by reserving address space, not actually allocating the RAM and/or backing store for that memory.
Over-commit is that called, right?
I'm sorry but that certainly wasn't the case here.
My machine has 512 Mb RAM and about 250 Mb of them
allocated when I tried it. (physical RAM that is)
Very weird, I cannot reproduce the initial crash I experienced.
--Irmen This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Srijit Kumar Bhadra |
last post by:
Hello,
Here is some sample code with pywin32 build 203 and ctypes 0.9.6.
Best regards,
/Srijit
File: SharedMemCreate_Mutex_win32all.py
# This application should be used with SharedMemAccess_Mutex_ctypes.py
or SharedMemAccess_Mutex_win32all.py
|
by: alanrn |
last post by:
I would like to start a dialog on how to implement the equivalent
functionality of UNIX shared memory in .NET. I work with a factory
automation system. The bulk of the system is written in C/C++. It was
ported from UNIX to run under Windows using .NET. If for no other reason
than as an educational exercise, I have been wondering what it...
|
by: Michael Schuler |
last post by:
The use of STL in shared memory poses a real problem since
(non-smart) pointers are not allowed there.
Is there any solution for containers in shared memory using
smart pointers? Where can I find templates?
|
by: myren, lord |
last post by:
When I first discovered shared memory (between multiple processes) I
immediately started thinking of how to build my own VM subsystem +
locking mechanisms for a large single block of memory. This seems like
one option, the other appears to be just having each "object" you want
to share be a shared mem space to itself: allocate objects into a...
|
by: phil_gg04 |
last post by:
Dear C++ Experts,
Over the last couple of months I have been writing my first program
using shared memory. It has been something of an "in-at-the-deep-end"
experience, to say the least. At present the shared memory contains a
few fixed-size structs, but I really need to be able to store more
complex variable-sized data in there. So the...
| |
by: Jeremy |
last post by:
Hi all,
I'm getting very confused about how DB2 uses shared memory and I
wonder if someone could clarify matters for me, please ?
We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine with 64
Gb of memory with a single non-partitioned database using extended
storage and with intra-parallelism enabled.
I've been experimenting...
|
by: Jim |
last post by:
Hello,
I have a broken server that we are going to be moving off to a new server
with a new version of DB2 but here is what I have right now:
RedHat 7.0 (2.2.24smp)
DB2 v6.1.0.40
I am getting this error when I try to run the command 'db2 "backup database
dbname online to /opt/BACKUP"' on my 3 databases:
SQL1042C An unexpected system...
|
by: Sebastjan Trepca |
last post by:
Hey!
Are there any "live" modules for working with shared memory in Python?
I found some but they are all dead(posh,shm)...
Thanks, Sebastjan
|
by: herbert |
last post by:
I am coding a dozen "background" realtime apps for factory automation in .NET
2.0.
The apps need to share a common memory as there are lots of variables to be
shared (and synchronized of course).
I need distinct apps for reasons like user interaction/access rights, error
compartments, and because the size of the code, access to various...
|
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...
|
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...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |