Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

EEM: context_save and mutex

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

Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: EEM: context_save and mutex

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.

3 REPLIES
Cisco Employee

Re: EEM: context_save and mutex

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.

New Member

Re: EEM: context_save and mutex

Thanks for the information.

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

Cisco Employee

Re: EEM: context_save and mutex

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.

324
Views
0
Helpful
3
Replies