473,414 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

any_srv (async server for whatever you want --default metakit)

Any_srv is a simple rpc library that is based off of async_chat. It
grew out of the desire to make metakit available to other processes
without have to manually expose all of it and to keep in sync with
future library changes.

To do this the client is 100% stupid. It has no knowledge about the
library and the server knows nothing except for importing it. This
means it could just as easily "serve" the string library as well as a
metakit database.

How it is managed is by using __getattr__ to capture requests in the
client process and remote them to the server. Anything that is
pickelable is sent back to the client. Otherwise effectively a
reference is sent back that the client can refer to. Iteratorable
libraries are also supported. So if you make a database request (like
in metakit), you can iterate through it's rows and get the data back
in chunks.

Start the server with:
python any_srv.py

Here is example client code:
String library exposed:

mclient=any_srv.Client()
print mclient.split('fred barney wilma')
['fred', 'barney', 'wilma']
print mclient.join(['betty','bambam','dino'])
betty bambam dino

And just as easily Metakit exposed:

mclient=any_server.Client()
#Create a database:
db = mclient.storage("datafile.mk",1)

print 'Create a view'
vw = db.getas("people[first:S,last:S,bowling:I]")

print 'Add a couple of rows'
vw.append(first='Fred',last='Flint',bowl=250)
vw.append(first='Barney',last='Rubble',bowl=150)

print 'Commit the changes to file:'
db.commit()

print 'Show a list of all people:'
for r in vw: print r.first(), r.last(),r.bowl()

mclient.any_server_clean()

2 things to think about:

1)Need to explicity kill (perhaps with a try: finally: block) the
object references. You can do that with: mclient.any_server_clean()

2)Currently, attributes as well as methods end in (), since everything
is remoted to the server.

The code is at version .01 a bit rough and needs to have more
features/documentation (like specifying a port and library to expose
at runtime)
but it seems to work well.

It is at:

http://savannah.nongnu.org/download/pytunnel/any_srv.py
http://savannah.nongnu.org/download/...meta_client.py

john
Jul 18 '05 #1
0 1037

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
0
by: Bill Guttman | last post by:
I am Invoking a Web Service on a remote server from my local server from the Data Entry Screen, I a recieve the following error "HTTP 500 - Internal server error Internet Explorer" Whats...
4
by: Macca | last post by:
I am writing an application that uses asynchronous sockets to get data over ethernet from embedded devices, up to 30 concurrent devices.(These devices are written in C). My application...
1
by: Ryman | last post by:
Hello, I've just recently began network programming for c# (bought the book C# Network Programming) and I've ran into a few problems. Whenever I click the submit button on the client (to send the UDP...
2
by: mikeshore | last post by:
I have one table with 42 fields. When creating a new record, I would like to create 42 variables using the field names, then set the values of these variables to the default values of the fields. Is...
4
by: nyhetsgrupper | last post by:
Hi, I've written a async server app. This app start by connecting to a client and then send some data (BeginSend). When the data is sent, the server is starting to listen for incomming data....
5
by: Barry | last post by:
I've wasted the whole day trying things and researching, but nothing is working. I would *greatly* appreciate if someone can give me the solution to this problem. I'm using the .NET Framework...
2
by: sqlgirl | last post by:
Hi, We have 2 servers. Server1 is a 2000 box, with SP3 (yes I know it is not up to date). Server2 is a 2005 box, SP2. I set up Server1 (2000) to have a linked server to Server2 (2005). The...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.