cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
753
Views
0
Helpful
3
Replies

EEM: context_save and mutex

bbrodfuehrer
Level 1
Level 1

Are there any limits to the types of data structure that context_save and context_retrieve can handle? For instance, will they work for a list?

Secondly, are the any mutex routines provided by any of the libraries? I need to be able to have two different scripts read the same context_save data and would like to be able to use a mutex to prevent both scripts from accessing the data at the same time.

Thanks,

Benjamin

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

No, there is no limit to what a context can hold.  I regularly stick arrays and lists into contexts.  You'll need to build your own mutexes.  You can use contexts for this, but there is a risk of a race since when you read from a context the data in the context is cleared.  You could use other methods like configuring an EEM environment variable then looping on "show event manager environment VAR" until the variable disappears.

View solution in original post

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

No, there is no limit to what a context can hold.  I regularly stick arrays and lists into contexts.  You'll need to build your own mutexes.  You can use contexts for this, but there is a risk of a race since when you read from a context the data in the context is cleared.  You could use other methods like configuring an EEM environment variable then looping on "show event manager environment VAR" until the variable disappears.

Thanks for the information.

I had considered using contexts to build a mutex, but hadn't thought about the environment variable approach, interesting.

I still use contexts to build mutexes.  If you don't have a narrow margin of error, then that's fine.  If you need to be more careful about races, then the environment variable approach is a bit safer.

Review Cisco Networking for a $25 gift card