# Do Import and Get work asynchronously? Can I prevent this?

I'm getting strange behavior in some of my notebooks that makes it seem like Import and Get load asynchronously. When I evaluate many cells together (for example, when I evaluate initialization cells), it seems as if Import, and sometimes Get, are "done" before the load is complete, so that subsequent cells are executed before loaded data (or executed commands) in the external file have have been fully loaded or executed.

For example, I have

data = Import["some data"];


and later in my notebook

something = doSomethingWith[data];


and I execute these cells together (e.g. as initialization cells), I get errors that indicate bad or non-existant values for data.

Similarly, when I have,

<<MySettings


and later

someSettingInMySettings = someModification;


I end up with the value for someSettingInMySettings that's defined in MySettings rather than someModification.

Do Import and Get load asynchronously? If so, is there a way to "wait" until they have completed before proceeding with evaluation?

-
Load is not a standard function. Did you get it from a package? Get is not asynchronous. – Szabolcs Dec 16 '12 at 0:14
@Szabolcs: Sorry, Import; fixing now. – raxacoricofallapatorius Dec 16 '12 at 0:15
Do you have the Import in separate initialization cell before the later initialization cell that uses the stuff imported? or are they in the same cell? – Nasser Dec 16 '12 at 0:30
I don't remember having this problem, they've always "waited" in my experience I think – Rojo Dec 16 '12 at 1:54
Can you put together a small reproducible example, complete with the file imported? I have never seen the problem you describe. There are things that don't take effect until the next evaluation cell, but they're usually related to parsing (e.g. changes to the context path), and never importing. – Szabolcs Dec 16 '12 at 6:21